mdmath_core/index/
slice.rs

1use super::{ AsIx2, Ix, Ix2, AsIx3, Ix3 };
2
3impl AsIx2 for &[ Ix ]
4{
5  #[ inline( always ) ]
6  fn as_ix2( self ) -> Ix2
7  {
8    assert!( self.len() == 2, "Slice must have exactly 2 elements for Ix2 conversion" );
9    #[allow(clippy::indexing_slicing)] // Safe due to length assertion above
10    return Ix2( self[ 0 ], self[ 1 ] )
11  }
12}
13
14impl AsIx3 for &[ Ix ]
15{
16  #[ inline( always ) ]
17  fn as_ix3( self ) -> Ix3
18  {
19    assert!( self.len() == 3, "Slice must have exactly 3 elements for Ix3 conversion" );
20    #[allow(clippy::indexing_slicing)] // Safe due to length assertion above
21    return Ix3( self[ 0 ], self[ 1 ], self[ 2 ] )
22  }
23}