@@ -2393,10 +2393,7 @@ impl<'a, T> Iterator for RChunks<'a, T> {
23932393 } else {
23942394 // Can't underflow because of the check above
23952395 let end = self . v . len ( ) - end;
2396- let start = match end. checked_sub ( self . chunk_size ) {
2397- Some ( sum) => sum,
2398- None => 0 ,
2399- } ;
2396+ let start = end. saturating_sub ( self . chunk_size ) ;
24002397 let nth = & self . v [ start..end] ;
24012398 self . v = & self . v [ 0 ..start] ;
24022399 Some ( nth)
@@ -2416,10 +2413,7 @@ impl<'a, T> Iterator for RChunks<'a, T> {
24162413
24172414 unsafe fn __iterator_get_unchecked ( & mut self , idx : usize ) -> Self :: Item {
24182415 let end = self . v . len ( ) - idx * self . chunk_size ;
2419- let start = match end. checked_sub ( self . chunk_size ) {
2420- None => 0 ,
2421- Some ( start) => start,
2422- } ;
2416+ let start = end. saturating_sub ( self . chunk_size ) ;
24232417 // SAFETY: mostly identical to `Chunks::__iterator_get_unchecked`.
24242418 unsafe { from_raw_parts ( self . v . as_ptr ( ) . add ( start) , end - start) }
24252419 }
@@ -2596,10 +2590,7 @@ impl<'a, T> Iterator for RChunksMut<'a, T> {
25962590
25972591 unsafe fn __iterator_get_unchecked ( & mut self , idx : usize ) -> Self :: Item {
25982592 let end = self . v . len ( ) - idx * self . chunk_size ;
2599- let start = match end. checked_sub ( self . chunk_size ) {
2600- None => 0 ,
2601- Some ( start) => start,
2602- } ;
2593+ let start = end. saturating_sub ( self . chunk_size ) ;
26032594 // SAFETY: see comments for `RChunks::__iterator_get_unchecked` and
26042595 // `ChunksMut::__iterator_get_unchecked`, `self.v`.
26052596 unsafe { from_raw_parts_mut ( self . v . as_mut_ptr ( ) . add ( start) , end - start) }
0 commit comments