问题
Something like this?
[String, 0]
Vec::new()
is not an option.
回答1:
This creates an empty array:
let thing: [String; 0] = [];
You can also get a slice from the array:
let thing: &[String] = &[];
You can also use as
:
some_function([] as [String; 0]);
some_function(&[] as &[String]);
来源:https://stackoverflow.com/questions/45533699/is-there-a-way-to-initialize-an-empty-slice