Simplify unsafe pointer code in SmallVec::pop

This commit is contained in:
Matt Brubeck
2017-09-19 16:06:59 -07:00
parent 09316926d5
commit 4151964cc8
+2 -2
View File
@@ -412,8 +412,8 @@ impl<A: Array> SmallVec<A> {
panic!("overflow")
}
unsafe {
let end_ptr = self.as_mut_ptr().offset(last_index as isize);
let value = ptr::replace(end_ptr, mem::uninitialized());
let end_ptr = self.as_ptr().offset(last_index as isize);
let value = ptr::read(end_ptr);
self.set_len(last_index);
Some(value)
}