mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 12:44:40 +00:00
parent
760942d7d2
commit
248cb90dfa
@ -155,7 +155,7 @@ pub unsafe fn replace_ptr<T>(dest: *mut T, mut src: T) -> T {
|
|||||||
* Reads the value from `*src` and returns it. Does not copy `*src`.
|
* Reads the value from `*src` and returns it. Does not copy `*src`.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn read_ptr<T>(src: *mut T) -> T {
|
pub unsafe fn read_ptr<T>(src: *T) -> T {
|
||||||
let mut tmp: T = intrinsics::uninit();
|
let mut tmp: T = intrinsics::uninit();
|
||||||
copy_nonoverlapping_memory(&mut tmp, src, 1);
|
copy_nonoverlapping_memory(&mut tmp, src, 1);
|
||||||
tmp
|
tmp
|
||||||
@ -168,7 +168,7 @@ pub unsafe fn read_ptr<T>(src: *mut T) -> T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn read_and_zero_ptr<T>(dest: *mut T) -> T {
|
pub unsafe fn read_and_zero_ptr<T>(dest: *mut T) -> T {
|
||||||
// Copy the data out from `dest`:
|
// Copy the data out from `dest`:
|
||||||
let tmp = read_ptr(dest);
|
let tmp = read_ptr(&*dest);
|
||||||
|
|
||||||
// Now zero out `dest`:
|
// Now zero out `dest`:
|
||||||
zero_memory(dest, 1);
|
zero_memory(dest, 1);
|
||||||
|
@ -1527,7 +1527,7 @@ impl<T> OwnedVector<T> for ~[T] {
|
|||||||
let valptr = ptr::to_mut_unsafe_ptr(&mut self[ln - 1u]);
|
let valptr = ptr::to_mut_unsafe_ptr(&mut self[ln - 1u]);
|
||||||
unsafe {
|
unsafe {
|
||||||
raw::set_len(self, ln - 1u);
|
raw::set_len(self, ln - 1u);
|
||||||
Some(ptr::read_ptr(valptr))
|
Some(ptr::read_ptr(&*valptr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user