Skip to content
← All tracks

Closures and Iterators

Rust

How idiomatic Rust is actually written: `Fn`/`FnMut`/`FnOnce`, capture modes, adapters and custom iterators. Performance appears here for the first time — displayed, not graded.

This track is written for Rust, which isn't the mode you're browsing in.

0 / 25 solved · 3 articles
  1. 1. Not solved yet. Closures 101: build a pipeline of boxed closures
  2. 2. Not solved yet. Fn, FnMut, FnOnce: the closure hierarchy
  3. 3. Not solved yet. move: when the closure must own its captures
  4. 4. Disjoint field capture: what changed in edition 2021 Read
  5. 5. Not solved yet. iter, iter_mut, into_iter: all three, one Vec
  6. 6. Not solved yet. IntoIterator: one bound that accepts five containers
  7. 7. Not solved yet. The double-reference wall: &&x, copied and cloned
  8. 8. Not solved yet. Laziness: prove the pipeline interleaves
  9. 9. Not solved yet. map, filter, filter_map: parse host:port lines
  10. 10. Not solved yet. fold and try_fold: a total that refuses to overflow
  11. 11. Not solved yet. take_while and skip_while: split a message at the blank line
  12. 12. Not solved yet. zip and enumerate: pair two lists and report the leftovers
  13. 13. Not solved yet. peekable and next_if: write a tokeniser
  14. 14. Not solved yet. flat_map: expand a range spec like "1-3,7,10-12"
  15. 15. Not solved yet. scan: a running balance that stops at the floor
  16. 16. Not solved yet. Implement Iterator by hand: the Collatz sequence
  17. 17. Not solved yet. from_fn and successors: iterators without writing a struct
  18. 18. Not solved yet. any, all, find, position: audit a list of records
  19. 19. Not solved yet. min and max: the tie-breaking rule nobody reads
  20. 20. Not solved yet. partition and unzip: two collections from one pass
  21. 21. Not solved yet. collect and the turbofish: three targets, one source
  22. 22. Not solved yet. size_hint and DoubleEndedIterator: an iterator with two ends
  23. 23. Not solved yet. Write your own adapters, with an extension trait
  24. 24. Not solved yet. Make your own collection iterable, all three ways
  25. 25. When collect() is a mistake Read
  26. 26. Not solved yet. Chains versus loops: top-k, and a function that must not allocate
  27. 27. Not solved yet. The FnMut borrow gauntlet: a log you can read afterwards
  28. 28. Iterator internals: why for and fold are not the same loop Read

Check yourself

4 questions · one attempt each

These do not count toward finishing the track. They are here to catch the things that are easy to read past.

0 / 4

What does move change about a closure?

let s = String::from("owned");
let c = move || s.len();
Question 1 of 4