@@ -895,13 +895,11 @@ impl<A, D: Dimension> ArrayRef<A, D>
895895 #[ inline]
896896 pub unsafe fn uget < I > ( & self , index : I ) -> & A
897897 where I : NdIndex < D >
898- {
899- unsafe {
900- arraytraits:: debug_bounds_check ( self , & index) ;
901- let off = index. index_unchecked ( & self . strides ) ;
902- & * self . ptr . as_ptr ( ) . offset ( off)
903- }
904- }
898+ { unsafe {
899+ arraytraits:: debug_bounds_check ( self , & index) ;
900+ let off = index. index_unchecked ( & self . strides ) ;
901+ & * self . ptr . as_ptr ( ) . offset ( off)
902+ } }
905903
906904 /// Perform *unchecked* array indexing.
907905 ///
@@ -920,14 +918,12 @@ impl<A, D: Dimension> ArrayRef<A, D>
920918 #[ inline]
921919 pub unsafe fn uget_mut < I > ( & mut self , index : I ) -> & mut A
922920 where I : NdIndex < D >
923- {
924- unsafe {
925- // debug_assert!(self.data.is_unique());
926- arraytraits:: debug_bounds_check ( self , & index) ;
927- let off = index. index_unchecked ( & self . strides ) ;
928- & mut * self . ptr . as_ptr ( ) . offset ( off)
929- }
930- }
921+ { unsafe {
922+ // debug_assert!(self.data.is_unique());
923+ arraytraits:: debug_bounds_check ( self , & index) ;
924+ let off = index. index_unchecked ( & self . strides ) ;
925+ & mut * self . ptr . as_ptr ( ) . offset ( off)
926+ } }
931927
932928 /// Swap elements at indices `index1` and `index2`.
933929 ///
@@ -968,16 +964,14 @@ impl<A, D: Dimension> ArrayRef<A, D>
968964 /// for `Array` and `ArrayViewMut`, but not for `ArcArray` or `CowArray`.)
969965 pub unsafe fn uswap < I > ( & mut self , index1 : I , index2 : I )
970966 where I : NdIndex < D >
971- {
972- unsafe {
973- // debug_assert!(self.data.is_unique());
974- arraytraits:: debug_bounds_check ( self , & index1) ;
975- arraytraits:: debug_bounds_check ( self , & index2) ;
976- let off1 = index1. index_unchecked ( & self . strides ) ;
977- let off2 = index2. index_unchecked ( & self . strides ) ;
978- std:: ptr:: swap ( self . ptr . as_ptr ( ) . offset ( off1) , self . ptr . as_ptr ( ) . offset ( off2) ) ;
979- }
980- }
967+ { unsafe {
968+ // debug_assert!(self.data.is_unique());
969+ arraytraits:: debug_bounds_check ( self , & index1) ;
970+ arraytraits:: debug_bounds_check ( self , & index2) ;
971+ let off1 = index1. index_unchecked ( & self . strides ) ;
972+ let off2 = index2. index_unchecked ( & self . strides ) ;
973+ std:: ptr:: swap ( self . ptr . as_ptr ( ) . offset ( off1) , self . ptr . as_ptr ( ) . offset ( off2) ) ;
974+ } }
981975
982976 // `get` for zero-dimensional arrays
983977 // panics if dimension is not zero. otherwise an element is always present.
@@ -1766,9 +1760,9 @@ where
17661760 #[ inline]
17671761 pub ( crate ) unsafe fn raw_view_mut_unchecked ( & mut self ) -> RawArrayViewMut < A , D >
17681762 where S : DataOwned
1769- {
1770- unsafe { RawArrayViewMut :: new ( self . ptr , self . dim . clone ( ) , self . strides . clone ( ) ) }
1771- }
1763+ { unsafe {
1764+ RawArrayViewMut :: new ( self . ptr , self . dim . clone ( ) , self . strides . clone ( ) )
1765+ } }
17721766
17731767 /// Return the array’s data as a slice, if it is contiguous and in standard order.
17741768 /// Return `None` otherwise.
@@ -2448,21 +2442,21 @@ impl<A, D: Dimension> ArrayRef<A, D>
24482442 self . view ( )
24492443 . into_dimensionality :: < <D as DimMax < E > >:: Output > ( )
24502444 . unwrap ( )
2451- } else if let Some ( view1 ) = self . broadcast ( shape. clone ( ) ) {
2445+ } else { match self . broadcast ( shape. clone ( ) ) { Some ( view1 ) => {
24522446 view1
2453- } else {
2447+ } _ => {
24542448 return Err ( from_kind ( ErrorKind :: IncompatibleShape ) ) ;
2455- } ;
2449+ } } } ;
24562450 let view2 = if shape. slice ( ) == other. dim . slice ( ) {
24572451 other
24582452 . view ( )
24592453 . into_dimensionality :: < <D as DimMax < E > >:: Output > ( )
24602454 . unwrap ( )
2461- } else if let Some ( view2 ) = other. broadcast ( shape. clone ( ) ) {
2455+ } else { match other. broadcast ( shape) { Some ( view2 ) => {
24622456 view2
2463- } else {
2457+ } _ => {
24642458 return Err ( from_kind ( ErrorKind :: IncompatibleShape ) ) ;
2465- } ;
2459+ } } } ;
24662460 Ok ( ( view1, view2) )
24672461 }
24682462}
@@ -3356,14 +3350,12 @@ impl<A, D: Dimension> ArrayRef<A, D>
33563350#[ track_caller]
33573351#[ inline]
33583352unsafe fn unlimited_transmute < A , B > ( data : A ) -> B
3359- {
3360- unsafe {
3361- // safe when sizes are equal and caller guarantees that representations are equal
3362- assert_eq ! ( size_of:: <A >( ) , size_of:: <B >( ) ) ;
3363- let old_data = ManuallyDrop :: new ( data) ;
3364- ( & * old_data as * const A as * const B ) . read ( )
3365- }
3366- }
3353+ { unsafe {
3354+ // safe when sizes are equal and caller guarantees that representations are equal
3355+ assert_eq ! ( size_of:: <A >( ) , size_of:: <B >( ) ) ;
3356+ let old_data = ManuallyDrop :: new ( data) ;
3357+ ( & * old_data as * const A as * const B ) . read ( )
3358+ } }
33673359
33683360type DimMaxOf < A , B > = <A as DimMax < B > >:: Output ;
33693361
0 commit comments