Macro array_macro::array [] [src]

macro_rules! array {
    [@INTERNAL $callback:expr; $count:expr] => { ... };
    [| $($rest:tt)*] => { ... };
    [move $($rest:tt)*] => { ... };
    [$expr:expr; $count:expr] => { ... };
}

Array constructor macro.

This macro provides a way to repeat the same macro element multiple times without requiring Copy implementation.

It's possible to define a callback by starting expression with | or move. As every closure is it own unique type, it is not possible to have an array of closures, so this syntax was reused for creating arrays with known indexes.

Examples

assert_eq!(array!["string"; 3], ["string", "string", "string"]);
assert_eq!(array![|x| x; 3], [0, 1, 2]);