Macro smallvec
macro_rules! smallvec {
(@one $x:expr) => { ... };
() => { ... };
($elem:expr; $n:expr) => { ... };
($($x:expr),+$(,)?) => { ... };
}
Creates a SmallVec containing the arguments.
smallvec! allows SmallVecs to be defined with the same syntax as array expressions.
There are two forms of this macro:
- Create a
SmallVeccontaining a given list of elements:
# use ;
#
- Create a
SmallVecfrom a given element and size:
# use ;
#
Note that unlike array expressions this syntax supports all elements
which implement Clone and the number of elements doesn't have to be
a constant.
This will use clone to duplicate an expression, so one should be careful
using this with types having a nonstandard Clone implementation. For
example, smallvec![Rc::new(1); 5] will create a vector of five references
to the same boxed integer value, not five references pointing to independently
boxed integers.