expression

Iterator consumption — keep or move the cursor

Methods taking self consume the receiver, unless a copy or a borrowed iterator is passed. Methods taking &mut self advance the same iterator and may leave a remaining suffix. Build a fresh iterator to traverse a collection again. Expected stdout (not executed): Some(1) remaining=3 Common mistake: Expecting count to leave the owned iterator available for reuse.

Formal Syntax & Structure

rust syntaxrust
iter.next(); iter.count();

Working Example

Example Snippetrust
fn main() {    let mut jobs = 1..5;    println!("{:?}", jobs.next());    println!("remaining={}", jobs.count());}
Rust Reference