Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Iterator trait

The trait with one required method, next, that every iterator implements.

Iterator declares type Item and fn next(&mut self) -> OptionSelf::Item; every adapter and consumer method is a provided method built on next.

Loading interactive…

Examples

  • Writing only fn next(&mut self) -> Option<u64> for a Hailstone struct gives it enumerate, take_while, sum and every other iterator method.

Read the full section →