Use RawPtr::offset when size_of::<T>() > 0

This commit is contained in:
Dan Schatzberg 2014-09-04 17:59:28 -04:00
parent 4184396f28
commit f14cb96b07

View File

@ -848,7 +848,11 @@ impl<T> Vec<T> {
let ptr = self.ptr;
let cap = self.cap;
let begin = self.ptr as *const T;
let end = (self.ptr as uint + self.len()) as *const T;
let end = if mem::size_of::<T>() == 0 {
(ptr as uint + self.len()) as *const T;
} else {
ptr.offset(self.len() as int)
};
mem::forget(self);
MoveItems { allocation: ptr, cap: cap, ptr: begin, end: end }
}