Skip to content

Feature request: Tracked adapter #957

Open
@advantageous-overtake

Description

@advantageous-overtake

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions