macro_rules! dimr {
    ( $a:ident..$b:ident ) => { ... };
    ( $a:ident..=$b:ident ) => { ... };
    ( $a:ident..$b:expr ) => { ... };
    ( $a:ident..=$b:expr ) => { ... };
    ( ..$a:ident ) => { ... };
    ( ..=$a:ident ) => { ... };
    ( $a:ident.. ) => { ... };
}
Expand description

Converts a range of identifiers and expressions to a range of usize values

Using any identifiers apart from x, y, z or w will result in a compile time error

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

Possible Variations:

/*
 PLEASE NOTE!
 x = 0usize
 y = 1
 z = 2
 w = 3
 */

// Range with identifiers
assert_eq!(dimr!(x..z), 0..2usize);

// RangeInclusive with identifiers
assert_eq!(dimr!(y..=w), 1..=3usize);

// RangeTo with identifiers
assert_eq!(dimr!(..z), ..2);

// RangeToInclusive with identifiers
assert_eq!(dimr!(..=w), ..=3);

// RangeFrom with identifier
assert_eq!(dimr!(y..), 1..);

// Range with identifier and expression
assert_eq!(dimr!(x..10), 0..10usize);

// RangeInclusive with identifier and expression
assert_eq!(dimr!(x..=7), 0..=7usize);

This is especially useful when taking slices of a PointND

let p = PointND::new([0,1,2,3,4,5]);
let slice = &p[dimr!(x..=z)];
assert_eq!(slice, [0,1,2]);