@@ -395,7 +395,7 @@ impl<A: Array> SmallVec<A> {
395
395
let mut data = SmallVecData :: < A > :: from_inline ( mem:: uninitialized ( ) ) ;
396
396
let len = vec. len ( ) ;
397
397
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) ;
399
399
400
400
SmallVec {
401
401
capacity : len,
@@ -516,7 +516,7 @@ impl<A: Array> SmallVec<A> {
516
516
let ( ptr, len) = self . data . heap ( ) ;
517
517
( ptr, len, self . capacity )
518
518
} else {
519
- ( self . data . inline ( ) . ptr ( ) , self . capacity , A :: size ( ) )
519
+ ( self . data . inline ( ) . as_ptr ( ) , self . capacity , A :: size ( ) )
520
520
}
521
521
}
522
522
}
@@ -529,7 +529,7 @@ impl<A: Array> SmallVec<A> {
529
529
let & mut ( ptr, ref mut len_ptr) = self . data . heap_mut ( ) ;
530
530
( ptr, len_ptr, self . capacity )
531
531
} 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 ( ) )
533
533
}
534
534
}
535
535
}
@@ -597,7 +597,7 @@ impl<A: Array> SmallVec<A> {
597
597
return ;
598
598
}
599
599
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) ;
601
601
self . capacity = len;
602
602
} else if new_cap != cap {
603
603
let mut vec = Vec :: with_capacity ( new_cap) ;
@@ -663,7 +663,7 @@ impl<A: Array> SmallVec<A> {
663
663
unsafe {
664
664
let ( ptr, len) = self . data . heap ( ) ;
665
665
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) ;
667
667
deallocate ( ptr, self . capacity ) ;
668
668
self . capacity = len;
669
669
}
@@ -987,7 +987,7 @@ impl<A: Array> SmallVec<A> where A::Item: Copy {
987
987
capacity : len,
988
988
data : SmallVecData :: from_inline ( unsafe {
989
989
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) ;
991
991
data
992
992
} )
993
993
}
@@ -1484,12 +1484,12 @@ impl<'a, A: Array> IntoIterator for &'a mut SmallVec<A> {
1484
1484
pub unsafe trait Array {
1485
1485
/// The type of the array's elements.
1486
1486
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 ;
1487
1491
/// Returns the number of items the array can hold.
1488
1492
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 ;
1493
1493
}
1494
1494
1495
1495
/// Set the length of the vec when the `SetLenOnDrop` value goes out of scope.
@@ -1529,9 +1529,9 @@ macro_rules! impl_array(
1529
1529
$(
1530
1530
unsafe impl <T > Array for [ T ; $size] {
1531
1531
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( ) }
1532
1534
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( ) }
1535
1535
}
1536
1536
) +
1537
1537
}
0 commit comments