From 41ac96e87b31ab5378b0374a69f6e9839070f4b9 Mon Sep 17 00:00:00 2001 From: Grumme2 <agh@live.se> Date: Thu, 20 Feb 2020 14:16:37 +0100 Subject: [PATCH] bare0_3 --- examples/bare0.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/bare0.rs b/examples/bare0.rs index 4e65073..c423a06 100644 --- a/examples/bare0.rs +++ b/examples/bare0.rs @@ -37,11 +37,10 @@ static mut Y: u32 = 0; fn main() -> ! { // local mutable variable (changed in safe code) let mut x = unsafe { X }; - loop { - x += 1; // <- place breakpoint here (3) + x = x.wrapping_add(1); // <- place breakpoint here (3) unsafe { - X += 1; + X = X.wrapping_add(1); Y = X; assert!(x == X && X == Y); } @@ -95,10 +94,10 @@ fn main() -> ! { // Change (both) += operations to use wrapping_add // load and run the program, what happens // ** your answer here ** -// +// x wraps around and becomes 0 and X doesnt change // Now continue execution, what happens // ** your answer here ** -// +// x continues to get bigger X is still the same // Commit your answers (bare0_3) // // (If the program did not succeed back to the breakpoint -- GitLab