Closed
Description
The docs for Vec::iter show the following type:
fn iter(&self) -> Iter<T>
As a result, I was puzzled that the following doesn't work:
let bar: Vec<&str> = vec!["a", "b", "c", "b"].iter().collect();
It turns out that that Iter
implements an iterator with element type &T. On the Iter docs page we see type Item = &'a T
but it's easy to overlook.
I think it would be worth adding a line to Vec::iter
's documentation to say:
Iterator element type is &T.
This is the approach taken in itertools docs (example) and I think it helps significantly.