@@ -150,20 +150,19 @@ pub trait Dimension : Clone + Eq + Debug + Send + Sync + Default +
150
150
strides
151
151
}
152
152
153
- #[ doc( hidden) ]
154
- // Return an index of same dimensionality
155
- fn zero_index ( & self ) -> Self {
156
- Self :: default ( )
157
- }
158
-
159
- #[ doc( hidden) ]
160
- /// Return an index of same type and with the specified dimensionality.
153
+ /// Creates a dimension of all zeros with the specified ndim.
161
154
///
162
155
/// This method is useful for generalizing over fixed-size and
163
156
/// variable-size dimension representations.
164
157
///
165
158
/// **Panics** if `Self` has a fixed size that is not `ndim`.
166
- fn zero_index_with_ndim ( ndim : usize ) -> Self ;
159
+ fn zeros ( ndim : usize ) -> Self ;
160
+
161
+ #[ doc( hidden) ]
162
+ // Return an index of same dimensionality
163
+ fn zero_index ( & self ) -> Self {
164
+ Self :: default ( )
165
+ }
167
166
168
167
#[ doc( hidden) ]
169
168
#[ inline]
@@ -380,7 +379,7 @@ impl Dimension for Dim<[Ix; 0]> {
380
379
#[ inline]
381
380
fn into_pattern ( self ) -> Self :: Pattern { }
382
381
#[ inline]
383
- fn zero_index_with_ndim ( ndim : usize ) -> Self {
382
+ fn zeros ( ndim : usize ) -> Self {
384
383
assert_eq ! ( ndim, 0 ) ;
385
384
Self :: default ( )
386
385
}
@@ -416,7 +415,7 @@ impl Dimension for Dim<[Ix; 1]> {
416
415
get ! ( & self , 0 )
417
416
}
418
417
#[ inline]
419
- fn zero_index_with_ndim ( ndim : usize ) -> Self {
418
+ fn zeros ( ndim : usize ) -> Self {
420
419
assert_eq ! ( ndim, 1 ) ;
421
420
Self :: default ( )
422
421
}
@@ -510,7 +509,7 @@ impl Dimension for Dim<[Ix; 2]> {
510
509
#[ inline]
511
510
fn slice_mut ( & mut self ) -> & mut [ Ix ] { self . ixm ( ) }
512
511
#[ inline]
513
- fn zero_index_with_ndim ( ndim : usize ) -> Self {
512
+ fn zeros ( ndim : usize ) -> Self {
514
513
assert_eq ! ( ndim, 2 ) ;
515
514
Self :: default ( )
516
515
}
@@ -655,7 +654,7 @@ impl Dimension for Dim<[Ix; 3]> {
655
654
}
656
655
657
656
#[ inline]
658
- fn zero_index_with_ndim ( ndim : usize ) -> Self {
657
+ fn zeros ( ndim : usize ) -> Self {
659
658
assert_eq ! ( ndim, 3 ) ;
660
659
Self :: default ( )
661
660
}
@@ -764,7 +763,7 @@ macro_rules! large_dim {
764
763
#[ inline]
765
764
fn slice_mut( & mut self ) -> & mut [ Ix ] { self . ixm( ) }
766
765
#[ inline]
767
- fn zero_index_with_ndim ( ndim: usize ) -> Self {
766
+ fn zeros ( ndim: usize ) -> Self {
768
767
assert_eq!( ndim, $n) ;
769
768
Self :: default ( )
770
769
}
@@ -822,7 +821,7 @@ impl Dimension for IxDyn
822
821
}
823
822
824
823
#[ inline]
825
- fn zero_index_with_ndim ( ndim : usize ) -> Self {
824
+ fn zeros ( ndim : usize ) -> Self {
826
825
IxDyn :: zeros ( ndim)
827
826
}
828
827
0 commit comments