Skip to content

ExactSizeIterator should not require DoubleEndedIterator; move rposition to extension trait #19395

@DanielKeep

Description

@DanielKeep

I have an iterator extension which performs an incremental calculation, yielding partial results along the way (technically a specialisation of scan).

I can easily implement ExactSizeIterator::len, provided the underlying iterator also implements it, but I cannot implement DoubleEndedIterator because that would require computing and caching all intermediate results.

I'm really not sure why rposition is even part of ExactSizeIterator; surely it should be an extension trait that requires both? Currently, it's presence prohibits implementing the len method which is the only part of ExactSize that might reasonably be expected to be there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions