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>()returns10.(1..).map(|n| n * n).find(|&sq| sq > 30)returnsSome(36)and stops pulling from the endless range after 6.
See also