File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -415,8 +415,7 @@ impl<T> Vec<T> {
415
415
unsafe { // infallible
416
416
// The spot to put the new value
417
417
{
418
- let slice = self . as_mut_slice ( ) ;
419
- let p = slice. as_mut_ptr ( ) . offset ( index as int ) ;
418
+ let p = self . as_mut_ptr ( ) . offset ( index as int ) ;
420
419
// Shift everything over to make space. (Duplicating the
421
420
// `index`th element into two consecutive places.)
422
421
ptr:: copy_memory ( p. offset ( 1 ) , & * p, len - index) ;
@@ -434,9 +433,8 @@ impl<T> Vec<T> {
434
433
unsafe { // infallible
435
434
let ret;
436
435
{
437
- let slice = self . as_mut_slice ( ) ;
438
436
// the place we are taking from.
439
- let ptr = slice . as_mut_ptr ( ) . offset ( index as int ) ;
437
+ let ptr = self . as_mut_ptr ( ) . offset ( index as int ) ;
440
438
// copy it out, unsafely having a copy of the value on
441
439
// the stack and in the vector at the same time.
442
440
ret = Some ( ptr:: read ( ptr as * T ) ) ;
@@ -499,6 +497,11 @@ impl<T> Vec<T> {
499
497
pub fn as_ptr ( & self ) -> * T {
500
498
self . as_slice ( ) . as_ptr ( )
501
499
}
500
+
501
+ #[ inline]
502
+ pub fn as_mut_ptr ( & mut self ) -> * mut T {
503
+ self . as_mut_slice ( ) . as_mut_ptr ( )
504
+ }
502
505
}
503
506
504
507
impl < T > Mutable for Vec < T > {
You can’t perform that action at this time.
0 commit comments