Puzzle 11Stacking Boxes
 fn​ ​main​() {
 let​ c = ​Box​::​new​([0u32; 10_000_000]);
  println!(​"{}"​, c​.len​());

Guess the Output


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


In debug mode, the program will crash with the message thread ’main’ has overflowed its stack. In release mode, the program will display the following output: 10000000.



10,000,000 32-bit integers requires 40Mb of memory ...

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.