Skip to content

Commit 33ecc33

Browse files
committed
use swap_unchecked in slice::reverse
1 parent 14769ce commit 33ecc33

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

library/core/src/slice/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,7 @@ impl<T> [T] {
707707
// The resulting pointers `pa` and `pb` are therefore valid and
708708
// aligned, and can be read from and written to.
709709
unsafe {
710-
// Unsafe swap to avoid the bounds check in safe swap.
711-
let ptr = self.as_mut_ptr();
712-
let pa = ptr.add(i);
713-
let pb = ptr.add(ln - i - 1);
714-
ptr::swap(pa, pb);
710+
self.swap_unchecked(i, ln - i - 1);
715711
}
716712
i += 1;
717713
}

0 commit comments

Comments
 (0)