@@ -1475,22 +1475,19 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> {
1475
1475
let remainder = self . v . len ( ) % self . chunk_size ;
1476
1476
let chunksz = if remainder != 0 { remainder } else { self . chunk_size } ;
1477
1477
// SAFETY: split_at_unchecked requires the argument be less than or
1478
- // equal to the length. This is guaranteed, but subtle: We need the
1479
- // expression `self.v.len() - sz` not to overflow, which means we
1480
- // need `sz >= tmp_len`.
1481
- //
1482
- // `sz` will always either be `self.v.len() % self.chunk_size`,
1483
- // which will always evaluate to strictly less than `self.v.len()`
1484
- // (or panic, in the case that `self.chunk_size` is zero), or it can
1485
- // be `self.chunk_size`, in the case that the length is exactly
1478
+ // equal to the length. This is guaranteed, but subtle: `chunksz`
1479
+ // will always either be `self.v.len() % self.chunk_size`, which
1480
+ // will always evaluate to strictly less than `self.v.len()` (or
1481
+ // panic, in the case that `self.chunk_size` is zero), or it can be
1482
+ // `self.chunk_size`, in the case that the length is exactly
1486
1483
// divisible by the chunk size.
1487
1484
//
1488
1485
// While it seems like using `self.chunk_size` in this case could
1489
1486
// lead to a value greater than `self.v.len()`, it cannot: if
1490
1487
// `self.chunk_size` were greater than `self.v.len()`, then
1491
- // `self.v.len() % self.chunk_size` would have returned non-zero
1492
- // (note that in this branch of the `if`, we already know that
1493
- // `self.v` is non-empty).
1488
+ // `self.v.len() % self.chunk_size` would return nonzero (note that
1489
+ // in this branch of the `if`, we already know that `self.v` is
1490
+ // non-empty).
1494
1491
let ( fst, snd) = unsafe { self . v . split_at_unchecked ( self . v . len ( ) - chunksz) } ;
1495
1492
self . v = fst;
1496
1493
Some ( snd)
@@ -2524,20 +2521,7 @@ impl<'a, T> DoubleEndedIterator for RChunks<'a, T> {
2524
2521
} else {
2525
2522
let remainder = self . v . len ( ) % self . chunk_size ;
2526
2523
let chunksz = if remainder != 0 { remainder } else { self . chunk_size } ;
2527
- // SAFETY: split_at_unchecked requires the argument be less than or
2528
- // equal to the length. This is guaranteed, but subtle: `chunksz`
2529
- // will always either be `self.v.len() % self.chunk_size`, which
2530
- // will always evaluate to strictly less than `self.v.len()` (or
2531
- // panic, in the case that `self.chunk_size` is zero), or it can be
2532
- // `self.chunk_size`, in the case that the length is exactly
2533
- // divisible by the chunk size.
2534
- //
2535
- // While it seems like using `self.chunk_size` in this case could
2536
- // lead to a value greater than `self.v.len()`, it cannot: if
2537
- // `self.chunk_size` were greater than `self.v.len()`, then
2538
- // `self.v.len() % self.chunk_size` would return nonzero (note that
2539
- // in this branch of the `if`, we already know that `self.v` is
2540
- // non-empty).
2524
+ // SAFETY: similar to Chunks::next_back
2541
2525
let ( fst, snd) = unsafe { self . v . split_at_unchecked ( chunksz) } ;
2542
2526
self . v = snd;
2543
2527
Some ( fst)
0 commit comments