Have we ever thought about adding making &[T]
implement IntoIterator<Item = T>
where T: Copy
(similarly to how extend
works)? Right now it’ quite annoying to take a function over slices:
fn foo(x: &[u32]) { .. }
and make it also accept iterators:
fn foo(x: impl IntoIterator<Item = u32>) { .. }
since all of the callers must become foo(x.iter().cloned())
. At least in a lot of the code bases I work on, this comes up most often with small, copy types, and it seems at least plausible that we might have &[T]
implement IntoIterator<Item = T>
when T: Copy
(not sure if it actually works).