Skip to content

enumerate should be generic over the integer #22716

Closed
@vks

Description

@vks

Currently enumerate uses usize for counting. This is necessary when iterating over slices (probably the most common scenario). However, in general an iterator is not necessarily related to memory, so it may make more sense to use other integer types.

It seems sensible to make enumerate generic over the integer type used for counting. This is backwards compatible, so it shouldn't break existing code.

pub struct Enumerate<I, T: Int> {
    iter: I,
    count: T
}

Would it be possible to make this change although enumerate is marked as stable?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-lowLow priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions