---
title: "Chapter 19: Closures and Iterators"
description: "The 8 lessons of chapter 19: Closures and Iterators, in teaching order."
url: "https://learnrust.net/chapter-19/"
last_updated: "2026-06-13"
---

# Chapter 19: Closures and Iterators

- [19.1 Closures](https://learnrust.net/chapter-19/closures.md): Closures are functions you can write inline and that capture variables from the surrounding scope, by reference or by move.
- [19.2 Closures and the Fn traits](https://learnrust.net/chapter-19/closures-and-the-fn-traits.md): How to take a closure as a parameter or return one, using the Fn, FnMut, and FnOnce traits, plus where plain function pointers fit.
- [19.3 The Iterator trait](https://learnrust.net/chapter-19/the-iterator-trait.md): What an iterator really is: the next method, the Item associated type, the iter/iter_mut/into_iter trio, and why iterators are lazy.
- [19.4 Iterator adapters](https://learnrust.net/chapter-19/iterator-adapters.md): The lazy transformers: map, filter, enumerate, zip, rev, and chain build one iterator from another without doing any work until consumed.
- [19.5 Consuming iterators](https://learnrust.net/chapter-19/consuming-iterators.md): The methods that drive an iterator to a result: collect and the turbofish, sum, count, fold, find, and the any/all short-circuiting checks.
- [19.6 For loops, demystified](https://learnrust.net/chapter-19/for-loops-demystified.md): How a for loop desugars into IntoIterator plus repeated next calls, finally paying off the promise made back in chapter 7.
- [19.7 Loops vs iterators](https://learnrust.net/chapter-19/loops-vs-iterators.md): Iterator pipelines compile to the same machine code as hand-written loops: the zero-cost claim, a benchmark, and when each style wins.
- [19.x Chapter 19 summary and quiz](https://learnrust.net/chapter-19/chapter-19-summary-and-quiz.md): Review of closures, the Fn traits, the Iterator trait, adapters, consumers, and the for-loop desugaring, with a capstone exercise.

## Sitemap

See the full [sitemap](https://learnrust.net/sitemap.md) for all pages.
