A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-75.rs
1fnmain(){
2letv:Vec<i32>=
3(1..4).map(|x|x*x).collect();
4println!("{:?}",v);
5}
Iteration
Answer & explanation
Console output
[1, 4, 9]
Why
The exclusive range 1..4 yields 1, 2, 3. map squares each (1, 4, 9) lazily, and collect drives the iterator and gathers the results into a Vec<i32>. The turbofish-free annotation Vec<i32> tells collect which collection to build.