From c920e1d1d9b9acbb0f562e809700a25fa49ba547 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 6 Apr 2015 07:30:01 +0200 Subject: [PATCH] Move some code outside of an `unsafe` block. --- lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib.rs b/lib.rs index 2968808..0dd92ef 100644 --- a/lib.rs +++ b/lib.rs @@ -221,9 +221,9 @@ macro_rules! def_small_vector( } pub fn grow(&mut self, new_cap: usize) { + let mut vec: Vec = Vec::with_capacity(new_cap); + let new_alloc = vec.as_mut_ptr(); unsafe { - let mut vec: Vec = Vec::with_capacity(new_cap); - let new_alloc = vec.as_mut_ptr(); mem::forget(vec); ptr::copy_nonoverlapping(self.begin(), new_alloc, self.len());