How can I initialize new Vector using the vec!
macro and automatically fill it up with values from an existing array? Here's the code example:
let a = [10, 20, 30, 40]; // a plain array
let v = vec![??]; // TODO: declare your vector here with the macro for vectors
What can I fill in (syntax wise) instead of the ???
characters?
Vec
implementsFrom<[T; N]>
. – Strawboardlet v = a.to_vec();
– Irmavec![]
can't create a new Vec from a Slice. – Irmaa
array. (I'm coming from c# background where there are no macros, so there is a possibility that I have poor understanding of macros) – Platy