@@ -2368,10 +2368,7 @@ impl<'a, T> Iterator for RChunks<'a, T> {
23682368 } else {
23692369 // Can't underflow because of the check above
23702370 let end = self . v . len ( ) - end;
2371- let start = match end. checked_sub ( self . chunk_size ) {
2372- Some ( sum) => sum,
2373- None => 0 ,
2374- } ;
2371+ let start = end. saturating_sub ( self . chunk_size ) ;
23752372 let nth = & self . v [ start..end] ;
23762373 self . v = & self . v [ 0 ..start] ;
23772374 Some ( nth)
@@ -2391,10 +2388,7 @@ impl<'a, T> Iterator for RChunks<'a, T> {
23912388
23922389 unsafe fn __iterator_get_unchecked ( & mut self , idx : usize ) -> Self :: Item {
23932390 let end = self . v . len ( ) - idx * self . chunk_size ;
2394- let start = match end. checked_sub ( self . chunk_size ) {
2395- None => 0 ,
2396- Some ( start) => start,
2397- } ;
2391+ let start = end. saturating_sub ( self . chunk_size ) ;
23982392 // SAFETY: mostly identical to `Chunks::__iterator_get_unchecked`.
23992393 unsafe { from_raw_parts ( self . v . as_ptr ( ) . add ( start) , end - start) }
24002394 }
@@ -2571,10 +2565,7 @@ impl<'a, T> Iterator for RChunksMut<'a, T> {
25712565
25722566 unsafe fn __iterator_get_unchecked ( & mut self , idx : usize ) -> Self :: Item {
25732567 let end = self . v . len ( ) - idx * self . chunk_size ;
2574- let start = match end. checked_sub ( self . chunk_size ) {
2575- None => 0 ,
2576- Some ( start) => start,
2577- } ;
2568+ let start = end. saturating_sub ( self . chunk_size ) ;
25782569 // SAFETY: see comments for `RChunks::__iterator_get_unchecked` and
25792570 // `ChunksMut::__iterator_get_unchecked`, `self.v`.
25802571 unsafe { from_raw_parts_mut ( self . v . as_mut_ptr ( ) . add ( start) , end - start) }
0 commit comments