@@ -41,6 +41,10 @@ pub trait Dimension : Clone + Eq + Debug + Send + Sync + Default +
41
41
MulAssign + for < ' x > MulAssign < & ' x Self > + MulAssign < usize >
42
42
43
43
{
44
+ /// For fixed-size dimension representations (e.g. `Ix2`), this should be
45
+ /// `Some(ndim)`, and for variable-size dimension representations (e.g.
46
+ /// `IxDyn`), this should be `None`.
47
+ const NDIM : Option < usize > ;
44
48
/// `SliceArg` is the type which is used to specify slicing for this
45
49
/// dimension.
46
50
///
@@ -350,6 +354,7 @@ macro_rules! impl_insert_axis_array(
350
354
) ;
351
355
352
356
impl Dimension for Dim < [ Ix ; 0 ] > {
357
+ const NDIM : Option < usize > = Some ( 0 ) ;
353
358
type SliceArg = [ Si ; 0 ] ;
354
359
type Pattern = ( ) ;
355
360
type Smaller = Self ;
@@ -381,6 +386,7 @@ impl Dimension for Dim<[Ix; 0]> {
381
386
382
387
383
388
impl Dimension for Dim < [ Ix ; 1 ] > {
389
+ const NDIM : Option < usize > = Some ( 1 ) ;
384
390
type SliceArg = [ Si ; 1 ] ;
385
391
type Pattern = Ix ;
386
392
type Smaller = Ix0 ;
@@ -469,6 +475,7 @@ impl Dimension for Dim<[Ix; 1]> {
469
475
}
470
476
471
477
impl Dimension for Dim < [ Ix ; 2 ] > {
478
+ const NDIM : Option < usize > = Some ( 2 ) ;
472
479
type SliceArg = [ Si ; 2 ] ;
473
480
type Pattern = ( Ix , Ix ) ;
474
481
type Smaller = Ix1 ;
@@ -599,6 +606,7 @@ impl Dimension for Dim<[Ix; 2]> {
599
606
}
600
607
601
608
impl Dimension for Dim < [ Ix ; 3 ] > {
609
+ const NDIM : Option < usize > = Some ( 3 ) ;
602
610
type SliceArg = [ Si ; 3 ] ;
603
611
type Pattern = ( Ix , Ix , Ix ) ;
604
612
type Smaller = Ix2 ;
@@ -710,6 +718,7 @@ impl Dimension for Dim<[Ix; 3]> {
710
718
macro_rules! large_dim {
711
719
( $n: expr, $name: ident, $pattern: ty, $larger: ty, { $( $insert_axis: tt) * } ) => (
712
720
impl Dimension for Dim <[ Ix ; $n] > {
721
+ const NDIM : Option <usize > = Some ( $n) ;
713
722
type SliceArg = [ Si ; $n] ;
714
723
type Pattern = $pattern;
715
724
type Smaller = Dim <[ Ix ; $n - 1 ] >;
@@ -756,6 +765,7 @@ large_dim!(6, Ix6, (Ix, Ix, Ix, Ix, Ix, Ix), IxDyn, {
756
765
/// and memory wasteful, but it allows an arbitrary and dynamic number of axes.
757
766
impl Dimension for IxDyn
758
767
{
768
+ const NDIM : Option < usize > = None ;
759
769
type SliceArg = [ Si ] ;
760
770
type Pattern = Self ;
761
771
type Smaller = Self ;
0 commit comments