Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Alternatively, we could create an iterator using the iter method

  • iter
fn main() {
    let numbers = vec![1, 2, 3];

    println!("{:?}", numbers);
    for n in numbers.iter() {
        println!("{}", n);
    }
    println!("{:?}", numbers);
}
[1, 2, 3]
1
2
3
[1, 2, 3]