macro_rules! sel_from_shape {
($shape:expr_2021, $label:ident = $range:expr_2021) => { ... };
($shape:expr_2021, $($label:ident = $val:literal),* $(,)?) => { ... };
($shape:expr_2021, $($label:ident = $range:expr_2021),* $(,)?) => { ... };
}
Expand description
Construct a Selection
from a Shape
using labeled dimension
constraints.
This macro provides a convenient syntax for specifying
sub-selections on a shape by labeling dimensions and applying
either exact indices or ranges. Internally, it wraps
selection_from_one
and selection_from
to produce a
fully-aligned Selection
expression.
§Forms
-
Single labeled range:
let shape = ndslice::shape!(zone = 2, host = 4, gpu = 8); let sel = ndslice::sel_from_shape!(&shape, host = 1..3);
-
Multiple exact indices (converted to
n..n+1
):let shape = ndslice::shape!(zone = 2, host = 4, gpu = 8); let sel = ndslice::sel_from_shape!(&shape, zone = 1, gpu = 4);
-
Multiple labeled ranges:
let shape = ndslice::shape!(zone = 2, host = 4, gpu = 8); let sel = ndslice::sel_from_shape!(&shape, zone = 0..1, host = 1..3, gpu = 4..8);
§Panics
This macro calls .unwrap()
on the result of the underlying
functions. It will panic if any label is not found in the shape.