Puzzle 12Amnesia
 fn​ ​main​() {
 loop​ {
 let​ buffer = (0..1000).collect::<Vec<u32>>();
 std​::​mem​::​forget​(buffer);
  print!(​"."​);
  }
 }

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, forever:

 .
images/hline.png

Discussion

The program running endlessly isn’t surprising since the program loops forever without a break to stop the loop. The surprise comes ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.