Puzzle 18Mutable Immutables
 fn​ ​main​() {
 let​ life_the_universe = &​mut​ 41;
  *life_the_universe += 1;
  println!(​"Life, the Universe and Everything: {}"​, life_the_universe);
 }

Guess the Output

images/aside-icons/important.png

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

images/hline.png

The program will display the following output:

 Life, the Universe and Everything: 42
images/hline.png

Discussion

The surprising part of this teaser is that the life_the_universe ...

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.