Repository: rust
Issue: Tracking Issue for `Iterator::array_chunks`
Labels: T-libs-api,C-tracking-issue,A-array

<!--
Thank you for creating a tracking issue!

Tracking issues are for tracking a feature from implementation to stabilization.

Make sure to include the relevant RFC for the feature if it has one.

If the new feature is small, it may be fine to skip the RFC process. In that
case, you can use use `issue = "none"` in your initial implementation PR. The
reviewer will ask you to open a tracking issue if they agree your feature can be
added without an RFC.
-->

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.

<!--
Include a short description of the feature.
-->

### Public API

<!--
For most library features, it'd be useful to include a summarized version of the public API.
(E.g. just the public function signatures without their doc comments or implementation.)
-->

```rust
// trait Iterator

fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>
where
    Self: Sized,self);
```
```rust
// 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

<!--
For larger features, more steps might be involved.
If the feature is changed later, please add those PRs here as well.
-->

- [x] Implementation: #100026
- [ ] Final comment period (FCP)[^1]
- [ ] Stabilization PR

<!--
Once the feature has gone through a few release cycles and there are no
unresolved questions left, the feature might be ready for stabilization.

If this feature didn't go through the RFC process, a final comment period
(FCP) is always needed before stabilization. This works as follows:

A library API team member can kick off the stabilization process, at which point
the rfcbot will ask all the team members to verify they agree with
stabilization. Once enough members agree and there are no concerns, the final
comment period begins: this issue will be marked as such and will be listed
in the next This Week in Rust newsletter. If no blocking concerns are raised in
that period of 10 days, a stabilzation PR can be opened by anyone.
-->

### Unresolved Questions

<!--
Include any open questions that need to be answered before the feature can be
stabilised. If multiple (unrelated) big questions come up, it can be a good idea
to open a separate issue for each, to make it easier to keep track of the
discussions.

It's useful to link any relevant discussions and conclusions (whether on GitHub,
Zulip, or the internals forum) here.
-->

- [ ] Should `DoubleEndedIterator` be 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 `DoubleEndedIterator` implementation should be improved
    - For example, maybe there should be `Iterator::next_chunk_back` like there is for forward
  - [ ] Is the `unwrap_err_unchecked` in `next_back_remainder` sound, despite not using `TrustedLen`?  (I didn't block the original PR on this because it goes through `take`, 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_chunks` has this question too and is unstable.)


[^1]: https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html