Puzzle 12 | Amnesia |
| fn main() { |
| loop { |
| let buffer = (0..1000).collect::<Vec<u32>>(); |
| std::mem::forget(buffer); |
| print!("."); |
| } |
| } |
Guess the Output | |
---|---|
Try to guess what the output is before moving to the next page. |
The program will display the following output, forever:
| . |
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.