typeover
rust curriculum

Curriculum Collections & iteration Iterators exercise 1 · mcq

Iterators

A function reads each element of a Vec<i32> to compute a sum, WITHOUT mutating or consuming the vector. Pick the iterator method that yields SHARED references.

TypeScript reference
Pick the idiomatic Go translation

About this theme

Idiomatic Rust often transforms data with iterators instead of manual indexing. The key ownership distinction is .iter(), .iter_mut(), and .into_iter(). Planned exercises: 1. choose .iter() for reading. 2. recognise .into_iter() moves. 3. choose .map(...).collect(). 4. fill .filter. 5. fill .sum::<i32>(). 6. write a map-collect. 7. write an iterator chain that borrows. 8. translate TS map and filter. 9. fix a chain that consumes a vector too early.