rust/library/core/src/array
bors 1bc56185ee Auto merge of #139430 - scottmcm:polymorphic-array-into-iter, r=cuviper
Polymorphize `array::IntoIter`'s iterator impl

Today we emit all the iterator methods for every different array width.  That's wasteful since the actual array length never even comes into it -- the indices used are from the separate `alive: IndexRange` field, not even the `N` const param.

This PR switches things so that an `array::IntoIter<T, N>` stores a `PolymorphicIter<[MaybeUninit<T>; N]>`, which we *unsize* to `PolymorphicIter<[MaybeUninit<T>]>` and call methods on that non-`Sized` type for all the iterator methods.

That also necessarily makes the layout consistent between the different lengths of arrays, because of the unsizing.  Compare that to today <https://rust.godbolt.org/z/Prb4xMPrb>, where different widths can't even be deduped because the offset to the indices is different for different array widths.
2025-04-11 23:21:31 +00:00
..
iter PR feedback 2025-04-09 21:44:59 -07:00
ascii.rs Remove #[cfg(not(test))] gates in core 2025-03-06 13:21:59 -08:00
drain.rs Allow canonicalizing the array::map loop in trusted cases 2023-02-04 16:44:51 -08:00
equality.rs Import the 2021 prelude in the core crate 2024-03-25 13:12:06 -07:00
iter.rs Polymorphize array::IntoIter's iterator impl 2025-04-05 17:55:24 -07:00
mod.rs Promise array::from_fn in generated in order of increasing indices 2025-03-29 01:06:43 -07:00