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

consumer

A method that runs an iterator to the end (or until it has an answer) and returns a result.

A consumer calls next until it has its result, producing a value rather than a new iterator (collect, sum, count, fold, find, any, all, position).

Loading interactive…

Examples

  • (1..=4).sum::<u32>() returns 10.

  • (1..).map(|n| n * n).find(|&sq| sq > 30) returns Some(36) and stops pulling from the endless range after 6.

Read the full section →