macro_rules! stackvec {
[] => { ... };
[$elem:expr; $n:expr] => { ... };
[$($item:expr),+ $(,)?] => { ... };
}Expand description
Creates a StackVec containing the arguments.
The syntax is similar to vec!.
You must explicitly specify the container capacity. The number of elements cannot exceed the capacity.
When called with no arguments, its size is known at compile time.
When all elements are explicitly listed and each element can be evaluated at compile time
(e.g., [1, 2, 3, 4]), the compiler can also construct it at compile time.
However, if the [item; len] syntax is used, it relies on Clone,
which may need to be deferred to runtime (even for simple cases like [0; 5]).
§Panics
Panics if the number of elements exceed the capacity.
§Examples
let vec: StackVec<String, 10> = stackvec![];
let vec: StackVec<i64, 10> = stackvec![1; 5]; // Need to support Clone.
let vec: StackVec<_, 10> = stackvec![1, 2, 3, 4];