---
source: https://iinventedlight.com/library/notes/rust-iterators.md
title: "Iterators in Rust"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT or Apache-2.0 (rust-lang/book; Copyright (c) 2010 The Rust Project Developers; https://github.com/rust-lang/book/blob/main/LICENSE-MIT); MIT or Apache-2.0 (rust-lang/rust-by-example; Copyright (c) 2014 Jorge Aparicio; https://github.com/rust-lang/rust-by-example/blob/master/LICENSE-MIT); prose restates or closely paraphrases cited source lines"
license_family: rust-mit
rule_check: "needs rule check (family not in auto-publish rule; check.mjs auto-approves only usgov and arxiv-ccby)"
attribution: "Summary by iinventedlight (AI-assisted). Sources: The Rust Programming Language, Processing a Series of Items with Iterators - The Rust Programming Language, MIT or Apache-2.0 (rust-lang/book; Copyright (c) 2010 The Rust Project Developers; https://github.com/rust-lang/book/blob/main/LICENSE-MIT); Rust by Example, Iterators - Rust By Example, MIT or Apache-2.0 (rust-lang/rust-by-example; Copyright (c) 2014 Jorge Aparicio; https://github.com/rust-lang/rust-by-example/blob/master/LICENSE-MIT)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: Rust"
tags: ['rust', 'iterators', 'collections']
sources:
  - id: S1
    title: "Processing a Series of Items with Iterators - The Rust Programming Language"
    publisher: The Rust Programming Language
    url: https://doc.rust-lang.org/book/ch13-02-iterators.html
    accessed: 2026-11-04
    license: "MIT or Apache-2.0 (rust-lang/book; Copyright (c) 2010 The Rust Project Developers; https://github.com/rust-lang/book/blob/main/LICENSE-MIT)"
  - id: S2
    title: "Iterators - Rust By Example"
    publisher: Rust by Example
    url: https://doc.rust-lang.org/rust-by-example/trait/iter.html
    accessed: 2026-11-04
    license: "MIT or Apache-2.0 (rust-lang/rust-by-example; Copyright (c) 2014 Jorge Aparicio; https://github.com/rust-lang/rust-by-example/blob/master/LICENSE-MIT)"
---
# Iterators in Rust

**Answer:** The iterator pattern allows you to perform some task on a sequence of items in turn. In Rust, iterators are lazy, meaning they have no effect until you call methods that consume the iterator to use it up. (S1)

## How they work

- An iterator is responsible for the logic of iterating over each item and determining when the sequence has finished. (S1)
- Implementing the Iterator trait requires that you also define an Item type, and this Item type is used in the return type of the next method. (S1)
- Calling the next method on an iterator changes internal state that the iterator uses to keep track of where it is in the sequence. (S1)
- Each call to next eats up an item from the iterator. (S1)

## In practice

- The Iterator trait is used to implement iterators over collections such as arrays. (S2)
- As a point of convenience for common situations, the for construct turns some collections into iterators using the .into_iter() method. (S2)

## Claims
- id: C1
  claim: Rust iterators are lazy.
  source: S1
  evidence: "In Rust, iterators are lazy"
- id: C2
  claim: Iterator requires an Item type.
  source: S1
  evidence: "this code says implementing the Iterator trait requires that you also define"
- id: C3
  claim: next changes internal state.
  source: S1
  evidence: "Calling the next method on an iterator"
- id: C4
  claim: for uses into_iter.
  source: S2
  evidence: "turns some collections into iterators using the .into_iter() method."

## Sources
- [S1] Processing a Series of Items with Iterators - The Rust Programming Language. The Rust Programming Language. https://doc.rust-lang.org/book/ch13-02-iterators.html . License: MIT or Apache-2.0 (rust-lang/book; Copyright (c) 2010 The Rust Project Developers; https://github.com/rust-lang/book/blob/main/LICENSE-MIT). Accessed 2026-11-04.
- [S2] Iterators - Rust By Example. Rust by Example. https://doc.rust-lang.org/rust-by-example/trait/iter.html . License: MIT or Apache-2.0 (rust-lang/rust-by-example; Copyright (c) 2014 Jorge Aparicio; https://github.com/rust-lang/rust-by-example/blob/master/LICENSE-MIT). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
