@@ -250,6 +250,7 @@ where
250250 let mut offsets_l = [ MaybeUninit :: < u8 > :: uninit ( ) ; BLOCK ] ;
251251
252252 // The current block on the right side (from `r.sub(block_r)` to `r`).
253+ // SAFETY: The documentation for .add() specifically mention that `vec.as_ptr().add(vec.len())` is always safe`
253254 let mut r = unsafe { l. add ( v. len ( ) ) } ;
254255 let mut block_r = BLOCK ;
255256 let mut start_r = ptr:: null_mut ( ) ;
@@ -435,12 +436,14 @@ where
435436 let mut l = 0 ;
436437 let mut r = v. len ( ) ;
437438 unsafe {
438- // Find the first element greater then or equal to the pivot.
439+ // Find the first element greater than or equal to the pivot.
440+ // SAFETY: We already do the bound checking here with `l<r`.
439441 while l < r && is_less ( v. get_unchecked ( l) , pivot) {
440442 l += 1 ;
441443 }
442444
443445 // Find the last element smaller that the pivot.
446+ // SAFETY: The minimum value for `l` is 0 and the maximum value for `r` is `v.len().`
444447 while l < r && !is_less ( v. get_unchecked ( r - 1 ) , pivot) {
445448 r -= 1 ;
446449 }
@@ -483,12 +486,14 @@ where
483486 let mut r = v. len ( ) ;
484487 loop {
485488 unsafe {
486- // Find the first element greater that the pivot.
489+ // Find the first element greater than the pivot.
490+ // SAFETY: We already do the bound checking here with `l<r`
487491 while l < r && !is_less ( pivot, v. get_unchecked ( l) ) {
488492 l += 1 ;
489493 }
490494
491495 // Find the last element equal to the pivot.
496+ // SAFETY: The minimum value for `l` is 0 and the maximum value for `r` is `v.len().`
492497 while l < r && is_less ( pivot, v. get_unchecked ( r - 1 ) ) {
493498 r -= 1 ;
494499 }
0 commit comments