File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ where
115115 /// Note that while this is similar to [`ArrayBase::as_slice_mut()`], this method tranfers the
116116 /// view's lifetime to the slice.
117117 pub fn into_slice ( self ) -> Option < & ' a mut [ A ] > {
118- self . into_slice_ ( ) . ok ( )
118+ self . try_into_slice ( ) . ok ( )
119119 }
120120}
121121
@@ -173,7 +173,9 @@ where
173173 ElementsBaseMut :: new ( self )
174174 }
175175
176- pub ( crate ) fn into_slice_ ( self ) -> Result < & ' a mut [ A ] , Self > {
176+ /// Return the array’s data as a slice, if it is contiguous and in standard order.
177+ /// Otherwise return self in the Err branch of the result.
178+ pub ( crate ) fn try_into_slice ( self ) -> Result < & ' a mut [ A ] , Self > {
177179 if self . is_standard_layout ( ) {
178180 unsafe { Ok ( slice:: from_raw_parts_mut ( self . ptr . as_ptr ( ) , self . len ( ) ) ) }
179181 } else {
Original file line number Diff line number Diff line change @@ -294,7 +294,7 @@ where
294294{
295295 pub ( crate ) fn new ( self_ : ArrayViewMut < ' a , A , D > ) -> Self {
296296 IterMut {
297- inner : match self_. into_slice_ ( ) {
297+ inner : match self_. try_into_slice ( ) {
298298 Ok ( x) => ElementsRepr :: Slice ( x. iter_mut ( ) ) ,
299299 Err ( self_) => ElementsRepr :: Counted ( self_. into_elements_base ( ) ) ,
300300 } ,
You can’t perform that action at this time.
0 commit comments