diff options
| author | bors <bors@rust-lang.org> | 2014-03-17 00:21:59 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-03-17 00:21:59 -0700 |
| commit | b6d5b8f6ff7b9feaf8f11e2624c6eeeeb5b3a9d9 (patch) | |
| tree | b4f8be389278d71ba083a142305131c3697d0280 /src/libstd | |
| parent | eb68beec4b809c1e091ce678a2c18347701497c2 (diff) | |
| parent | 5db7f7ed2413476e2006af6068d1b3a53e00db38 (diff) | |
| download | rust-b6d5b8f6ff7b9feaf8f11e2624c6eeeeb5b3a9d9.tar.gz rust-b6d5b8f6ff7b9feaf8f11e2624c6eeeeb5b3a9d9.zip | |
auto merge of #12945 : cadencemarseille/rust/vec_ng-as_mut_ptr, r=alexcrichton
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/vec_ng.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/libstd/vec_ng.rs b/src/libstd/vec_ng.rs index 7b77a4b60fb..d36617e1924 100644 --- a/src/libstd/vec_ng.rs +++ b/src/libstd/vec_ng.rs @@ -415,8 +415,7 @@ impl<T> Vec<T> { unsafe { // infallible // The spot to put the new value { - let slice = self.as_mut_slice(); - let p = slice.as_mut_ptr().offset(index as int); + let p = self.as_mut_ptr().offset(index as int); // Shift everything over to make space. (Duplicating the // `index`th element into two consecutive places.) ptr::copy_memory(p.offset(1), &*p, len - index); @@ -434,9 +433,8 @@ impl<T> Vec<T> { unsafe { // infallible let ret; { - let slice = self.as_mut_slice(); // the place we are taking from. - let ptr = slice.as_mut_ptr().offset(index as int); + let ptr = self.as_mut_ptr().offset(index as int); // copy it out, unsafely having a copy of the value on // the stack and in the vector at the same time. ret = Some(ptr::read(ptr as *T)); @@ -499,6 +497,11 @@ impl<T> Vec<T> { pub fn as_ptr(&self) -> *T { self.as_slice().as_ptr() } + + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut T { + self.as_mut_slice().as_mut_ptr() + } } impl<T> Mutable for Vec<T> { |
