The Vec
type has an implementation of the IntoIterator
trait for mutable vectors:
impl<'a, T> IntoIterator for &'a mut Vec<T> {
type Item = &'a mut T;
type IntoIter = slice::IterMut<'a, T>;
fn into_iter(self) -> slice::IterMut<'a, T> {
self.iter_mut()
}
}
I am not able to get that code invoked. I am trying:
let mut vec = vec![1, 2, 3];
for mut i in &vec {
println!("{}", i);
}
What usage of Vec
will invoke that particular IntoIterator
implementation?