From e6cfe7609c4a3a20a90b132d17000da2cda2820c Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Wed, 29 Nov 2017 12:14:36 -0800 Subject: [PATCH] Use copy_nonoverlapping in insert_from_slice Since this method takes a unique reference to `self`, we know that it can't overlap with `slice`. --- lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib.rs b/lib.rs index 3cfa797..bafd654 100644 --- a/lib.rs +++ b/lib.rs @@ -669,7 +669,7 @@ impl SmallVec where A::Item: Copy { let slice_ptr = slice.as_ptr(); let ptr = self.as_mut_ptr().offset(index as isize); ptr::copy(ptr, ptr.offset(slice.len() as isize), len - index); - ptr::copy(slice_ptr, ptr, slice.len()); + ptr::copy_nonoverlapping(slice_ptr, ptr, slice.len()); self.set_len(len + slice.len()); } }