Closed tower120 closed 11 months ago
If I do let wrapper = &mut iter;
(or let wrapper = iter.by_ref();
) then the code works the exact same way. So I don't see the interest of this wrapper if it has the same behavior as &mut I
.
Am I missing something here?
I think you might be looking for Iterator::by_ref
. Does that fit your use-case?
You're right! I was not aware about by_ref
iterator idiom in Rust.
Motivation
Have C++ 20/23 Ranges
base()
iterator access -like functionality.This may be needed when base iterator type provide some additional functionality.
Request
By having iterator wrapper around
&mut impl Iterator
we can wrap some iterator into any kind of adapter (for example Skip), use that adapted iterator (next-ing), and then still have access tobase
iterator, without Rc RefCell overhead.