Fundamentally, I don't want my type to be generic over all implementations. I want a concrete type. I want the type returned by one specific, often private, function.
But, nope. Not today. Maybe with TAIT, whenever that ships.
Could this problem be reformulated to use associated types, rather than full generics?
I want to make another struct which slowly consumes that impl Iterator. So, the second struct is struct MyStruct { iter: (iterator returned from that function above) }.
Unfortunately, the iterator type doesn’t have a name. So currently that means it’s impossible to put this iterator in a struct.
This makes anything returned via impl Iterator (and impl Future and so on) second class citizens in rust. You are very limited in the ways you can use these objects compared to normal values.
My code is filled with hand written iterators that I could construct much more easily with map/filter/fold and friends. But I make them the long way simply so the resulting type has a name. The current situation is very silly.