Skip to content

Tracking Issue for Iterator::exactly_one and Iterator::collect_array #149266

@jdonszelmann

Description

@jdonszelmann

Feature gate: #![feature(exact_length_collection)]

This is a tracking issue for exact length collection, concerning originally one but after discussion two new APIs on iterators:

  • exactly_one() to collect the one and only element from an iterator
  • collect_array() to collect an iterator into an array of an exact predetermined length.

Public API

// trait Iterator

// note: unlike itertools, returns an Option, not a result as per ACP
fn exactly_one(self) -> Option<Self::Item>
where
    Self: Sized;
fn collect_array<const N: usize>(self) -> Option<[Self::Item; N]>
where
    Self: Sized;

Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libsRelevant to the library 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