diff --git a/src/collections/raw_vec.rs b/src/collections/raw_vec.rs index 0abf43a06ac1d39f500751c698e40150ded015b4..088430ecf66725df09cb21e7c4edf7b675f80a37 100644 --- a/src/collections/raw_vec.rs +++ b/src/collections/raw_vec.rs @@ -70,7 +70,7 @@ impl RawVec { debug_assert!(additional > 0); let new_cap = self.len.checked_add(additional).unwrap(); let new_cap = cmp::max(new_cap, self.cap * Self::GROWTH_RATE); - + let layout = Layout::array::(new_cap) .map_err(|_| AllocError::CapacityOverflow)?; debug_assert_eq!(new_cap * Self::T_SIZE, layout.size()); @@ -83,7 +83,7 @@ impl RawVec { let old_base = self.base as *mut u8; let (old_size, old_layout) = self.current_layout(); - ptr::copy_nonoverlapping(new_base, old_base, old_size); + ptr::copy_nonoverlapping(old_base, new_base, old_size); dealloc(old_base, old_layout); }