File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 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> {
415415 unsafe { // infallible
416416 // The spot to put the new value
417417 {
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 ) ;
420419 // Shift everything over to make space. (Duplicating the
421420 // `index`th element into two consecutive places.)
422421 ptr:: copy_memory ( p. offset ( 1 ) , & * p, len - index) ;
@@ -434,9 +433,8 @@ impl<T> Vec<T> {
434433 unsafe { // infallible
435434 let ret;
436435 {
437- let slice = self . as_mut_slice ( ) ;
438436 // 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 ) ;
440438 // copy it out, unsafely having a copy of the value on
441439 // the stack and in the vector at the same time.
442440 ret = Some ( ptr:: read ( ptr as * T ) ) ;
@@ -499,6 +497,11 @@ impl<T> Vec<T> {
499497 pub fn as_ptr ( & self ) -> * T {
500498 self . as_slice ( ) . as_ptr ( )
501499 }
500+
501+ #[ inline]
502+ pub fn as_mut_ptr ( & mut self ) -> * mut T {
503+ self . as_mut_slice ( ) . as_mut_ptr ( )
504+ }
502505}
503506
504507impl < T > Mutable for Vec < T > {
You can’t perform that action at this time.
0 commit comments