Puzzle 4: Explanation
Let’s find out how counters and loops work in Rust.
Test it out
Hit “Run” to see the code’s output. The answer depends on how we run the program.
Running in debug mode
If we run the program in debug mode with cargo run
, the program will display a series of numbers from 0 to 127 and then crash while displaying the following error message:
thread 'main' panicked at 'attempt to add with overflow', main.rs:5:7.
Get hands-on with 1400+ tech skills courses.