-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-arrayArea: `[T; N]`Area: `[T; N]`C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Feature gate: #![feature(iter_array_chunks)]
This is a tracking issue for Iterator::array_chunks, an iterator adapter that allows to group elements of an iterator.
Public API
// trait Iterator
fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>
where
Self: Sized,self);// core::iter
pub struct ArrayChunks<I: Iterator, const N: usize> { ... }
impl<I, const N: usize> ArrayChunks<I, N> {
pub fn into_remainder(self) -> Option<array::IntoIter<I::Item, N>>;
}
impl<I: Iterator, const N: usize> Iterator for ArrayChunks<I, N> {
type Item = [I::Item; N];
}
impl<I: DoubleEndedIterator + ExactSizeIterator, const N: usize> DoubleEndedIterator for ArrayChunks<I, N> {}
impl<I: FusedIterator, const N: usize> FusedIterator for ArrayChunks<I, N> {}
impl<I: ExactSizeIterator, const N: usize> ExactSizeIterator for ArrayChunks<I, N> {}Steps / History
- Implementation: Add
Iterator::array_chunks(take N+1) #100026 - Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Should
DoubleEndedIteratorbe implemented?- Is there a use-case for this?
- In order to yield the same items either way we require
ExactSizeIterator - Note that
.rev().array_chunks()and.array_chunks().rev()are different - If we decide to keep
DoubleEndedIteratorimplementation should be improved- For example, maybe there should be
Iterator::next_chunk_backlike there is for forward
- For example, maybe there should be
- Is the
unwrap_err_uncheckedinnext_back_remaindersound, despite not usingTrustedLen? (I didn't block the original PR on this because it goes throughtake, which I think we can trust, but I'd like someone smarter than me to think about it and confirm.)
- Should this be a type error for
N != 0? (See also this same question in[T]::as_chunks.) - What's the tradeoff between the item type being
array::IntoIter<T, N>and the current one where the items are[T; N]and there's a remainder? ([T]::array_chunkshas this question too and is unstable.)
Footnotes
stepancheg, Iizuki, raldone01 and DrSensorjdahlstrom, IndigoLily, camelid, taxborn, jcornaz and 52 more
Metadata
Metadata
Assignees
Labels
A-arrayArea: `[T; N]`Area: `[T; N]`C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.