Skip to content

Commit 4e70e25

Browse files
committed
Modifies the Array trait
Method names are now matching std
1 parent 93f9909 commit 4e70e25

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ impl<A: Array> SmallVec<A> {
395395
let mut data = SmallVecData::<A>::from_inline(mem::uninitialized());
396396
let len = vec.len();
397397
vec.set_len(0);
398-
ptr::copy_nonoverlapping(vec.as_ptr(), data.inline_mut().ptr_mut(), len);
398+
ptr::copy_nonoverlapping(vec.as_ptr(), data.inline_mut().as_mut_ptr(), len);
399399

400400
SmallVec {
401401
capacity: len,
@@ -516,7 +516,7 @@ impl<A: Array> SmallVec<A> {
516516
let (ptr, len) = self.data.heap();
517517
(ptr, len, self.capacity)
518518
} else {
519-
(self.data.inline().ptr(), self.capacity, A::size())
519+
(self.data.inline().as_ptr(), self.capacity, A::size())
520520
}
521521
}
522522
}
@@ -529,7 +529,7 @@ impl<A: Array> SmallVec<A> {
529529
let &mut (ptr, ref mut len_ptr) = self.data.heap_mut();
530530
(ptr, len_ptr, self.capacity)
531531
} else {
532-
(self.data.inline_mut().ptr_mut(), &mut self.capacity, A::size())
532+
(self.data.inline_mut().as_mut_ptr(), &mut self.capacity, A::size())
533533
}
534534
}
535535
}
@@ -597,7 +597,7 @@ impl<A: Array> SmallVec<A> {
597597
return;
598598
}
599599
self.data = SmallVecData::from_inline(mem::uninitialized());
600-
ptr::copy_nonoverlapping(ptr, self.data.inline_mut().ptr_mut(), len);
600+
ptr::copy_nonoverlapping(ptr, self.data.inline_mut().as_mut_ptr(), len);
601601
self.capacity = len;
602602
} else if new_cap != cap {
603603
let mut vec = Vec::with_capacity(new_cap);
@@ -663,7 +663,7 @@ impl<A: Array> SmallVec<A> {
663663
unsafe {
664664
let (ptr, len) = self.data.heap();
665665
self.data = SmallVecData::from_inline(mem::uninitialized());
666-
ptr::copy_nonoverlapping(ptr, self.data.inline_mut().ptr_mut(), len);
666+
ptr::copy_nonoverlapping(ptr, self.data.inline_mut().as_mut_ptr(), len);
667667
deallocate(ptr, self.capacity);
668668
self.capacity = len;
669669
}
@@ -987,7 +987,7 @@ impl<A: Array> SmallVec<A> where A::Item: Copy {
987987
capacity: len,
988988
data: SmallVecData::from_inline(unsafe {
989989
let mut data: A = mem::uninitialized();
990-
ptr::copy_nonoverlapping(slice.as_ptr(), data.ptr_mut(), len);
990+
ptr::copy_nonoverlapping(slice.as_ptr(), data.as_mut_ptr(), len);
991991
data
992992
})
993993
}
@@ -1484,12 +1484,12 @@ impl<'a, A: Array> IntoIterator for &'a mut SmallVec<A> {
14841484
pub unsafe trait Array {
14851485
/// The type of the array's elements.
14861486
type Item;
1487+
/// Returns a mutable pointer to the first element of the array.
1488+
fn as_mut_ptr(&mut self) -> *mut Self::Item;
1489+
/// Returns a pointer to the first element of the array.
1490+
fn as_ptr(&self) -> *const Self::Item;
14871491
/// Returns the number of items the array can hold.
14881492
fn size() -> usize;
1489-
/// Returns a pointer to the first element of the array.
1490-
fn ptr(&self) -> *const Self::Item;
1491-
/// Returns a mutable pointer to the first element of the array.
1492-
fn ptr_mut(&mut self) -> *mut Self::Item;
14931493
}
14941494

14951495
/// Set the length of the vec when the `SetLenOnDrop` value goes out of scope.
@@ -1529,9 +1529,9 @@ macro_rules! impl_array(
15291529
$(
15301530
unsafe impl<T> Array for [T; $size] {
15311531
type Item = T;
1532+
fn as_mut_ptr(&mut self) -> *mut T { self.as_mut().as_mut_ptr() }
1533+
fn as_ptr(&self) -> *const T { self.as_ref().as_ptr() }
15321534
fn size() -> usize { $size }
1533-
fn ptr(&self) -> *const T { self.as_ptr() }
1534-
fn ptr_mut(&mut self) -> *mut T { self.as_mut_ptr() }
15351535
}
15361536
)+
15371537
}

0 commit comments

Comments
 (0)