1
Fork 0

std: clean up ptr a bit

This commit is contained in:
Corey Richardson 2014-02-14 18:42:01 -05:00
parent 3496e93d13
commit 49e11630fa
25 changed files with 128 additions and 220 deletions

View file

@ -22,7 +22,7 @@ use cast::{forget, transmute};
use rt::global_heap::{malloc_raw, realloc_raw};
use vec::{ImmutableVector, Items, MutableVector};
use unstable::raw::Slice;
use ptr::read_ptr;
use ptr;
use ptr::RawPtr;
use libc::{free, c_void};
@ -117,7 +117,7 @@ impl<T> Vec<T> {
} else {
unsafe {
self.len -= 1;
Some(read_ptr(self.as_slice().unsafe_ref(self.len())))
Some(ptr::read(self.as_slice().unsafe_ref(self.len())))
}
}
}
@ -147,7 +147,7 @@ impl<T> Vec<T> {
let mut i = len;
// drop any extra elements
while i < self.len {
read_ptr(self.as_slice().unsafe_ref(i));
ptr::read(self.as_slice().unsafe_ref(i));
i += 1;
}
}
@ -188,7 +188,7 @@ impl<T> Drop for Vec<T> {
fn drop(&mut self) {
unsafe {
for x in self.as_mut_slice().iter() {
read_ptr(x);
ptr::read(x);
}
free(self.ptr as *mut c_void)
}
@ -204,7 +204,7 @@ impl<T> Iterator<T> for MoveItems<T> {
#[inline]
fn next(&mut self) -> Option<T> {
unsafe {
self.iter.next().map(|x| read_ptr(x))
self.iter.next().map(|x| ptr::read(x))
}
}
@ -218,7 +218,7 @@ impl<T> DoubleEndedIterator<T> for MoveItems<T> {
#[inline]
fn next_back(&mut self) -> Option<T> {
unsafe {
self.iter.next_back().map(|x| read_ptr(x))
self.iter.next_back().map(|x| ptr::read(x))
}
}
}