Macro select

Source
macro_rules! select {
    ($shape:ident, $label:ident = $range:expr_2021) => { ... };
    ($shape:ident, $label:ident = $range:expr_2021, $($labels:ident = $ranges:expr_2021),+) => { ... };
}
Expand description

Perform a sub-selection on the provided Shape object.

This macro chains .select() calls to apply multiple labeled dimension restrictions in a fluent way.

let s = ndslice::shape!(host = 2, gpu = 8);
let s = ndslice::select!(s, host = 1, gpu = 4..).unwrap();
assert_eq!(s.labels(), &["host".to_string(), "gpu".to_string()]);
assert_eq!(s.slice().sizes(), &[1, 4]);