Search⌘ K

Puzzle 12: Amnesia

Explore Rust Puzzle 12 titled Amnesia by attempting to guess the output of a Rust program. This lesson helps learners understand important Rust concepts such as memory management and type conversion through practical problem solving.

We'll cover the following...

Guess the output

Before moving on to the explanation, try to guess the output of the following program. Good luck!

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

Quiz

Technical Quiz
1.

What is the output of the code above?

A.

The program loop runs forever since there’s no break keyword to stop it.

B.

The program prints a thousand dots (.) and exits.

C.

The program prints dots (.) for 10 seconds and then stops executing.


1 / 1