Skip to content

repeat_n's documentation lists impl ExactSizeIterator as a difference with repeat + Iterator::take, which is no longer the case #131872

Closed
@cyqsimon

Description

@cyqsimon

Location

https://doc.rust-lang.org/nightly/std/iter/fn.repeat_n.html

Summary

The newly stabalised std::iter::repeat_n states:

This is very similar to using repeat() with Iterator::take(), but there are two differences:

  • repeat_n() can return the original value, rather than always cloning.
  • repeat_n() produces an ExactSizeIterator.

But the second item is no longer true, since impl ExactSizeIterator for Take<Repeat<T>> and impl ExactSizeIterator for Take<RepeatWith<F>> now exist and are stable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-iteratorsArea: IteratorsT-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