address Mark-Simulacrum comments
This commit is contained in:
parent
a6d011a986
commit
af101fdc33
3 changed files with 8 additions and 11 deletions
|
@ -145,7 +145,7 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
|
|||
let mut tmp = MaybeUninit::<T>::uninitialized();
|
||||
|
||||
// Perform the swap
|
||||
copy_nonoverlapping(x, tmp.get_mut(), 1);
|
||||
copy_nonoverlapping(x, tmp.as_mut_ptr(), 1);
|
||||
copy(y, x, 1); // `x` and `y` may overlap
|
||||
copy_nonoverlapping(tmp.get_ref(), y, 1);
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub unsafe fn read<T>(src: *const T) -> T {
|
||||
let mut tmp = MaybeUninit::<T>::uninitialized();
|
||||
copy_nonoverlapping(src, tmp.get_mut(), 1);
|
||||
copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
|
||||
tmp.into_inner()
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,6 @@ union RawArray<T> {
|
|||
}
|
||||
|
||||
impl<T> RawArray<T> {
|
||||
fn ptr(&self) -> *mut T {
|
||||
unsafe { &self.typed as *const T as *mut T }
|
||||
}
|
||||
fn cap() -> usize {
|
||||
if mem::size_of::<T>() == 0 {
|
||||
usize::max_value()
|
||||
|
@ -85,8 +82,8 @@ pub unsafe fn ptr_rotate<T>(mut left: usize, mid: *mut T, mut right: usize) {
|
|||
}
|
||||
}
|
||||
|
||||
let rawarray = MaybeUninit::<RawArray<T>>::uninitialized();
|
||||
let buf = rawarray.get_ref().ptr();
|
||||
let mut rawarray = MaybeUninit::<RawArray<T>>::uninitialized();
|
||||
let buf = &mut (*rawarray.as_mut_ptr()).typed as *mut [T; 2] as *mut T;
|
||||
|
||||
let dim = mid.sub(left).add(right);
|
||||
if left <= right {
|
||||
|
|
|
@ -272,8 +272,8 @@ fn partition_in_blocks<T, F>(v: &mut [T], pivot: &T, is_less: &mut F) -> usize
|
|||
|
||||
if start_l == end_l {
|
||||
// Trace `block_l` elements from the left side.
|
||||
start_l = unsafe { offsets_l.get_mut().as_mut_ptr() };
|
||||
end_l = unsafe { offsets_l.get_mut().as_mut_ptr() };
|
||||
start_l = offsets_l.as_mut_ptr() as *mut u8;
|
||||
end_l = offsets_l.as_mut_ptr() as *mut u8;
|
||||
let mut elem = l;
|
||||
|
||||
for i in 0..block_l {
|
||||
|
@ -288,8 +288,8 @@ fn partition_in_blocks<T, F>(v: &mut [T], pivot: &T, is_less: &mut F) -> usize
|
|||
|
||||
if start_r == end_r {
|
||||
// Trace `block_r` elements from the right side.
|
||||
start_r = unsafe { offsets_r.get_mut().as_mut_ptr() };
|
||||
end_r = unsafe { offsets_r.get_mut().as_mut_ptr() };
|
||||
start_r = offsets_r.as_mut_ptr() as *mut u8;
|
||||
end_r = offsets_r.as_mut_ptr() as *mut u8;
|
||||
let mut elem = r;
|
||||
|
||||
for i in 0..block_r {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue