Skip to content
Snippets Groups Projects
Commit 41ac96e8 authored by Anton Grahn's avatar Anton Grahn
Browse files

bare0_3

parent e948d843
No related branches found
No related tags found
No related merge requests found
...@@ -37,11 +37,10 @@ static mut Y: u32 = 0; ...@@ -37,11 +37,10 @@ static mut Y: u32 = 0;
fn main() -> ! { fn main() -> ! {
// local mutable variable (changed in safe code) // local mutable variable (changed in safe code)
let mut x = unsafe { X }; let mut x = unsafe { X };
loop { loop {
x += 1; // <- place breakpoint here (3) x = x.wrapping_add(1); // <- place breakpoint here (3)
unsafe { unsafe {
X += 1; X = X.wrapping_add(1);
Y = X; Y = X;
assert!(x == X && X == Y); assert!(x == X && X == Y);
} }
...@@ -95,10 +94,10 @@ fn main() -> ! { ...@@ -95,10 +94,10 @@ fn main() -> ! {
// Change (both) += operations to use wrapping_add // Change (both) += operations to use wrapping_add
// load and run the program, what happens // load and run the program, what happens
// ** your answer here ** // ** your answer here **
// // x wraps around and becomes 0 and X doesnt change
// Now continue execution, what happens // Now continue execution, what happens
// ** your answer here ** // ** your answer here **
// // x continues to get bigger X is still the same
// Commit your answers (bare0_3) // Commit your answers (bare0_3)
// //
// (If the program did not succeed back to the breakpoint // (If the program did not succeed back to the breakpoint
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment