Macro axmac::axs

source · []
macro_rules! axs {
    ( $( $d:ident ), * ) => { ... };
    ( $d:ident; $i:expr ) => { ... };
}
Expand description

Converts an array of identifiers x, y, z or w to an array of usize values

Using any identifier or expression apart from the above will result in a compile time error

It is recommended to use square brackets when calling this macro for clarity

Possible Variations

// Explicitly specifying items in array
let arr =  axs![x, y, z, w];
assert_eq!(arr, [0, 1, 2, 3]);

// Repeat specified item N times
let arr =  axs![w; 4];
assert_eq!(arr, [3, 3, 3, 3]);

Using identifiers multiple times is allowed, this is only a more readable way to create arrays after all

let arr  =  axs![x,x, z,z, y,y];
assert_eq!(arr, [0,0, 2,2, 1,1]);