We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
swap_unchecked
slice::reverse
1 parent 14769ce commit 33ecc33Copy full SHA for 33ecc33
library/core/src/slice/mod.rs
@@ -707,11 +707,7 @@ impl<T> [T] {
707
// The resulting pointers `pa` and `pb` are therefore valid and
708
// aligned, and can be read from and written to.
709
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);
+ self.swap_unchecked(i, ln - i - 1);
715
}
716
i += 1;
717
0 commit comments