Puzzle 4Byte-Sized Chunks
 fn​ ​main​() {
 let​ ​mut​ counter : i8 = 0;
 loop​ {
  println!(​"{}"​, counter);
  counter += 1;

Guess the Output


Try to guess what the output is before moving to the next page.


The answer depends on how you run the program.

  • If you run the program in debug mode with cargo run, the program will display a series of numbers from 0 to 127 and then crash with the following error message: thread ’main’ panicked at ’attempt to add with overflow’, overflow\src\main.rs:6:9.

  • If you run the ...

Get Rust Brain Teasers now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.