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 can only instantiate arrays in such fashion if the type implements the Copy trait. This trait is only for types that can be copied byte by byte (and since vector points to heap, it can't be implemented).
One answer to this problem is the array_init crate that provides much more general way of initializing arrays in complicated fashion.
let multi: [Vec; 10] = array_init::array_init(|_| vec![0; 24]);