Hi! As a simplified example, I'm trying to create a struct that iterates over chars of str provided to the constructor, five at a time. Internally it just calls
.next() five times on the
std::str::Chars received from
s.chars() and stored in a field of its type. See the working example.
However, I don't use anything specific to
std::str::Chars, only the
.next() method of the
Iterator trait. So, I thought I could specify
T: Iterator<Item = char> as a field type where
std::str::Chars will be stored. And I tried, but it gives
expected type parameter `T`, found struct `Chars` error. See the not working example.
I feel like I'm doing something stupidly wrong, but I just can't find out what.
So, the question is, can I, and if so, how do I store
std::str::Chars in a struct field of type
Iterator<Item = char>?
Thanks in advance!