The most technically-correct answer to that question: make a Vec
of references:
array.iter_mut().collect::<Vec<_>>();
no cloning involved, and you have a Vec
.
In practice, however, it's gonna be lifetime-bound (Vec<&mut T>
or Vec<&T>
if using .iter()
).
Hence the following more useful answer, but it may involve cloning or other stuff: