File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -3271,7 +3271,8 @@ impl<T> [T] {
32713271 #[ inline]
32723272 #[ unstable( feature = "slice_take" , issue = "62280" ) ]
32733273 pub fn take_last < ' a > ( self : & mut & ' a Self ) -> Option < & ' a T > {
3274- self . take ( ( self . len ( ) - 1 ) ..) . map ( |res| & res[ 0 ] )
3274+ let i = self . len ( ) . checked_sub ( 1 ) ?;
3275+ self . take ( i..) . map ( |res| & res[ 0 ] )
32753276 }
32763277
32773278 /// Returns a mutable reference to the last element of the slice,
@@ -3294,7 +3295,8 @@ impl<T> [T] {
32943295 #[ inline]
32953296 #[ unstable( feature = "slice_take" , issue = "62280" ) ]
32963297 pub fn take_last_mut < ' a > ( self : & mut & ' a mut Self ) -> Option < & ' a mut T > {
3297- self . take_mut ( ( self . len ( ) - 1 ) ..) . map ( |res| & mut res[ 0 ] )
3298+ let i = self . len ( ) . checked_sub ( 1 ) ?;
3299+ self . take_mut ( i..) . map ( |res| & mut res[ 0 ] )
32983300 }
32993301}
33003302
You can’t perform that action at this time.
0 commit comments