I would like to create an array of vectors:
fn main() {
let v: [Vec; 10] = [Vec::new(); 10];
}
However, the compiler gives me t
You cannot use the [expr; N] initialisation syntax for non-Copy types because of Rust’s ownership model—it executes the expression once only, and for non-Copy types it cannot just copy the bytes N times, they must be owned in one place only.
You will need to either:
Write it out explicitly ten times: let v: [Vec, or
Use something like a vector instead of the array: std::iter::repeat(vec![]).take(10).collect::.
See also: