The following code:
struct Abc<I>
where I: Iterator<Item=u64> {
my_iter: I,
}
impl<I> Abc<I>
where I: Iterator<Item=u64> {
fn func1(&mut self) {
self.my_iter = vec![1,2,3,4,5].into_iter();
}
}
fails to compile with the following error:
error[E0308]: mismatched types
--> src/abc.rs:16:24
|
12 | impl<I> Abc<I>
| - this type parameter
...
16 | self.my_iter = vec![1,2,3,4,5].into_iter();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `I`, found struct `std::vec::IntoIter`
|
= note: expected type parameter `I`
found struct `std::vec::IntoIter<{integer}>`
Why it doesn't work and how to fix it?
Thanks!