Rust theorytheory 0/50 · 0%
Collections · easy

18. Iterators

Lazy, zero-cost pipelines.

Iterators are lazy: adapters like map, filter and take build a pipeline that only runs when a consumer such as collect, sum or for-loop drives it. Choose iter() to borrow, iter_mut() to mutate and into_iter() to consume.

Check your understanding

  1. 1. Iterator adapters are…

  2. 2. Which consumes the collection?