How do I initialize an array of vectors?

前端 未结 3 1872
我在风中等你
我在风中等你 2021-01-01 10:05

I would like to create an array of vectors:

fn main() {
    let v: [Vec; 10] = [Vec::new(); 10];
}

However, the compiler gives me t

3条回答
  •  有刺的猬
    2021-01-01 10:15

    You could use the Default trait to initialize the array with default values:

    let array: [Vec; 10] = Default::default();
    

    See this playground for a working example.

提交回复
热议问题