- iter
Alternatively, we could create an iterator using the iter method.
examples/iterators/iterator-over-vector-of-numbers-using-iter/src/main.rs
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]