let a = [0i32, 1, 2];let mut iter = a.iter().filter(|x| x.is_positive());let a = [0, 1, 2];let mut iter = a.iter().filter(|&x| *x > 1); // both & and *
iter() vs into_iter()
The iterator returned by into_iter may yield any of T, &T or &mut T, depending on the context.
The iterator returned by iter will yield &T, by convention.
The iterator returned by iter_mut will yield &mut T, by convention.
iter() returns an iterator over references to the elements of the collection, while into_iter() returns an iterator that takes ownership of the collection and returns its elements