Skip to content

Document what happens if std::iter::Take's n is greater than the amount of elements #61222

Closed
@KizzyCode

Description

@KizzyCode

The documentation of std::iter::Take gives no information about what happens if the underlying iterator yields less elements than Take should take.
Does it return less than n elements, does it panic, ...

Maybe we should change

An iterator that only iterates over the first n iterations of iter.

to something like

An iterator that only iterates over the first n iterations of iter. If iter yields less elements than n, only the amount of elements produced by iter will be returned.

However english is not my mother tongue and I'm pretty sure there is a much better formulation than this (even to my ears this sounds clumsy)^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-iteratorsArea: IteratorsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions