Open
Description
In my code I have the need to get the most recent index without having to store it every time I advance the CharIndices<'_>
iterator, so I propose the following:
A generic implementation for all Iterator<Item = (T, U)>
, with the adapter declared as:
struct Tracked<T, U, I>
where
T: Default,
I: Sized + Iterator<Item = (T, U)>
{
iter: I,
last: T
}
This allows generic integration with common adapters such as Enumerate<_>
.
The Default
requirement for T
could also be dropped and have an Option
there if the current design is undesired.