Rust iterators and closures: map, filter, write your own

11 steps · about 4 h 45 min · Intermediate

  1. Closures and Iterators · MeowyTheDev companion guide (guide, Zero to Rust, 15 min)

    A short overview that links iter, iter_mut and into_iter to the Fn, FnMut and FnOnce closure modes, so you start with the big picture.

  2. Iterators & Closures (guide, Luca Nerlich, 20 min)

    Shows closure syntax, passing closures as parameters, and calling next() by hand, which makes the basics concrete.

  3. Processing a Series of Items with Iterators - The Rust Programming Language (doc, The Rust Programming Language (official book), 25 min)

    The official explanation of the Iterator trait, adapters like map and filter, and closures that capture their environment.

  4. How to Use Closures with Iterators in Rust — Rust FAQ (article, Rust FAQ, 10 min)

    Covers the common |&n| versus |n| patterns and the FnMut borrow errors you'll hit when you start writing chains.

  5. A deep dive into Rust iterators and closures - LogRocket Blog (blog, LogRocket, 20 min)

    A second walk-through of the Iterator trait with worked examples, to reinforce the official book.

  6. Mastering Iterators and Closures in Rust (article, ByteMagma, 20 min)

    Explains consuming methods such as collect, fold and for_each, and sets up the move to writing your own iterator.

  7. How to Implement Custom Iterator in Rust (article, OneUptime, 20 min)

    Walks through building a custom iterator: a counter, infinite sequences, and IntoIterator for for-loops.

  8. Implementing Iterators in Rust & creating a random number generator! (video, YouTube, 20 min)

    Watch someone implement an infinite iterator live, which turns the written steps into practice.

  9. Iterator in Rust / Design Patterns (article, Refactoring.Guru, 15 min)

    Applies a custom iterator to a custom collection, with the borrowed iterator that real code uses.

  10. std::iter module documentation (reference, Rust standard library docs, 30 min)

    The authoritative reference for laziness, adapters, IntoIterator and what else you can override.

  11. Crust of Rust: Iterators (video, Jon Gjengset (YouTube), 1 h 30 min)

    An advanced capstone that re-implements the standard library's flatten, so you learn trait bounds and how adapters are built.