macro_rules! collect {
(@count_tts $($tts:tt)*) => { ... };
(@replace_expr $_tt:tt $sub:expr) => { ... };
(@collect
ty: $col_ty:ty,
es: [$v0:expr, $($vs:expr),* $(,)*],
// `cb` is an expression that is inserted after each "step" in constructing the collection. It largely exists for testing purposes.
cb: ($col:ident) $cb:expr,
) => { ... };
[] => { ... };
[as $col_ty:ty] => { ... };
[as $col_ty:ty:] => { ... };
[as $col_ty:ty: $v0:expr] => { ... };
[as $col_ty:ty: $v0:expr, $($vs:expr),* $(,)*] => { ... };
[as $col_ty:ty: $($ks:expr => $vs:expr),+ $(,)*] => { ... };
[$($vs:expr),+ $(,)*] => { ... };
[$($ks:expr => $vs:expr),+ $(,)*] => { ... };
}Expand description
This macro can be used to easily construct arbitrary collections, including Vec, String, and HashMap. It also endeavours to construct the collection with a single allocation, where possible.
For more details, see the crate documentation.