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
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 iteratorcollect_array()to collect an iterator into an array of an exact predetermined length.Public API
Steps / History
(Remember to update the
S-tracking-*label when checking boxes.)onlyon iterators libs-team#676Iterator::{exactly_one, collect_array}#149270Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩