Ok, I’m pretty new to Rust, so this might be a pretty stupid issue, but I’m banging my head against it and for the life of me I can’t figure out how to make this work.
Long story short, I want to implement the IntoIterator trait for an Iterator I have, so that I can use the “for in” loop syntax with it. But no matter what I do, I can’t make all of these things work out at the same time:
- I have to define the IntoIter associated type for IntoIterator
- The iterator type has a lifetime parameter because it has a reference to the container
- I can’t define a lifetime parameter in an associated type without the compiler saying that “the lifetime parameter
'ais not constrained by the impl trait, self type, or predicates”
I have uploaded a gist here with a sample showing the issue: https://gist.github.com/jonvaldes/e4abcbb250bf14a3041f
I’d be super grateful if anyone could help me figure this out!
Thanks in advance!