From 4151964cc8a43c11efaa880d71ffe48ba610e2ed Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Tue, 19 Sep 2017 16:06:59 -0700 Subject: [PATCH] Simplify unsafe pointer code in SmallVec::pop --- lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib.rs b/lib.rs index 208ebba..6128559 100644 --- a/lib.rs +++ b/lib.rs @@ -412,8 +412,8 @@ impl SmallVec { 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) }