Skip into_iter() for arrays before 2021

This commit is contained in:
Josh Stone
2021-04-12 16:07:28 -07:00
parent 35b1590223
commit 3dab4e22d4
5 changed files with 60 additions and 0 deletions

View File

@@ -155,6 +155,10 @@ impl<T: fmt::Debug, const N: usize> fmt::Debug for [T; N] {
}
}
// Note: the `#[rustc_skip_array_during_method_dispatch]` on `trait IntoIterator`
// hides this implementation from explicit `.into_iter()` calls on editions < 2021,
// so those calls will still resolve to the slice implementation, by reference.
#[cfg(not(bootstrap))]
#[stable(feature = "array_into_iter_impl", since = "1.53.0")]
impl<T, const N: usize> IntoIterator for [T; N] {
type Item = T;