Skip to content

It's surprising that Iterator::len consumes the iterator #14678

Closed
@erickt

Description

@erickt

The method Iterator::len() is surprising, as all the other uses of len() do not consume the value. len() would make more sense to be called count(), but that would collide with the current Iterator::count(|T| -> bool) -> unit method. That method, however, is a bit redundant, and can be easily replaced with iter.filter(|x| x < 5).count(). After this change, we could then define the len() method on iter::ExactSize.

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