Can it be argued that a vector (among other types of collections) is an Iterator ?
For example, I can iterate over a vector as follows, because it implements the Iterator trait (as I understand it):
let v = vec![1, 2, 3, 4, 5]; for x in &v { println!("{}", x); }
However, if I want to use functions that are part of the Iterator attribute (e.g. fold , map or filter ), why should I first call iter() on this vector?
Another thought that I had was perhaps that the vector can be converted to Iterator , in which case the syntax above makes sense.
iterator rust
Ralph caraveo
source share