Closed
Description
In #65819, we are considering adding an impl of IntoIterator
for [T; N]
for all N
. However, this breaks existing code that relies on method dispatch:
let array = [true; 3];
for x in array.into_iter() {
let _ = *x; // x is a reference
}
In this code, array.into_iter()
winds up unsizing to a slice and hence resolving to <&[bool] as IntoIterator>::into_iter
(and thus executing on refs to booleans). This issue describes a possible modification to older Rust editions that would allow us to add the impl without breaking existing code or compromising our edition guarantees.