Skip to content

Commit 0951617

Browse files
author
sarah el kazdadi
committed
chore: import core::ptr::copy instead of qualifying it
1 parent 3e2eeca commit 0951617

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ use core::mem::ManuallyDrop;
7575
use core::mem::MaybeUninit;
7676
use core::ptr::addr_of;
7777
use core::ptr::addr_of_mut;
78+
use core::ptr::copy;
7879
use core::ptr::copy_nonoverlapping;
7980

8081
use core::marker::PhantomData;
@@ -349,7 +350,7 @@ impl<'a, T: 'a, const N: usize> Drop for Drain<'a, T, N> {
349350
let ptr = source_vec.as_mut_ptr();
350351
let src = ptr.add(tail);
351352
let dst = ptr.add(start);
352-
core::ptr::copy(src, dst, self.tail_len);
353+
copy(src, dst, self.tail_len);
353354
}
354355
source_vec.set_len(start + self.tail_len);
355356
}
@@ -864,7 +865,7 @@ impl<T, const N: usize> SmallVec<T, N> {
864865
let ptr = self.as_mut_ptr();
865866
let ith = ptr.add(index);
866867
let ith_item = ith.read();
867-
core::ptr::copy(ith.add(1), ith, new_len - index);
868+
copy(ith.add(1), ith, new_len - index);
868869
ith_item
869870
}
870871
}
@@ -877,7 +878,7 @@ impl<T, const N: usize> SmallVec<T, N> {
877878
let ptr = self.as_mut_ptr();
878879
unsafe {
879880
if index < len {
880-
core::ptr::copy(ptr.add(index), ptr.add(index + 1), len - index);
881+
copy(ptr.add(index), ptr.add(index + 1), len - index);
881882
}
882883
ptr.add(index).write(value);
883884
self.set_len(len + 1);
@@ -1114,7 +1115,7 @@ impl<T: Copy, const N: usize> SmallVec<T, N> {
11141115
let base_ptr = self.as_mut_ptr();
11151116
let ith_ptr = base_ptr.add(index);
11161117
let shifted_ptr = base_ptr.add(index + other_len);
1117-
core::ptr::copy(ith_ptr, shifted_ptr, len - index);
1118+
copy(ith_ptr, shifted_ptr, len - index);
11181119
copy_nonoverlapping(slice.as_ptr(), ith_ptr, other_len);
11191120
self.set_len(len + other_len);
11201121
}
@@ -1180,7 +1181,7 @@ impl<T> Drop for DropShiftGuard<T> {
11801181
fn drop(&mut self) {
11811182
unsafe {
11821183
core::ptr::slice_from_raw_parts_mut(self.ptr, self.len).drop_in_place();
1183-
core::ptr::copy(self.shifted_ptr, self.ptr, self.shifted_len);
1184+
copy(self.shifted_ptr, self.ptr, self.shifted_len);
11841185
}
11851186
}
11861187
}
@@ -1206,7 +1207,7 @@ unsafe fn insert_many_batch_phase<T, I: Iterator<Item = T>>(
12061207
iter: &mut I,
12071208
) -> usize {
12081209
// shift elements to the right to make space for the initial elements from the iterator
1209-
core::ptr::copy(ptr.add(index), ptr.add(index + lower_bound), len - index);
1210+
copy(ptr.add(index), ptr.add(index + lower_bound), len - index);
12101211
let ptr_ith = ptr.add(index);
12111212
let mut guard = DropShiftGuard {
12121213
ptr: ptr_ith,
@@ -1222,7 +1223,7 @@ unsafe fn insert_many_batch_phase<T, I: Iterator<Item = T>>(
12221223
core::mem::forget(guard);
12231224

12241225
if count < lower_bound {
1225-
core::ptr::copy(ptr_ith.add(lower_bound), ptr_ith.add(count), len - index);
1226+
copy(ptr_ith.add(lower_bound), ptr_ith.add(count), len - index);
12261227
}
12271228
count
12281229
}

0 commit comments

Comments
 (0)