Macro axmac::ax

source · []
macro_rules! ax {
    (x) => { ... };
    (y) => { ... };
    (z) => { ... };
    (w) => { ... };
}
Expand description

Converts an identifier x, y, z or w to a usize value.

Using any identifier apart from the above or multiple identifiers will result in a compile time error.

It is recommended to use parentheses when calling this macro for clarity.

Possible Variations

let first: usize = ax!(x);
let second = ax!(y);
let third  = ax!(z);
let fourth = ax!(w);

assert_eq!(first,  0);
assert_eq!(second, 1);
assert_eq!(third,  2);
assert_eq!(fourth, 3);

// ERROR: Only allowed to use one of x, y, z or w
// let fifth_axis = ax!(v);

// ERROR: Only accepts one identifier
//        If multiple axes are what you need, see the 'axs' macro
// let third_and_fourth = ax!(z, w);