diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2016-03-02 07:01:16 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2016-03-02 07:01:16 +0530 |
| commit | b515bb3b6b6c50539f81bd6e3a1c3c9d92f43e40 (patch) | |
| tree | 827cd053fda15d863a39de82789e87128a6636db | |
| parent | fe565954ea358642ce6598c8f74f6f14b5a3fba0 (diff) | |
| parent | 63c4065af00a61aef24153a1d3dde76013f433bb (diff) | |
| download | rust-b515bb3b6b6c50539f81bd6e3a1c3c9d92f43e40.tar.gz rust-b515bb3b6b6c50539f81bd6e3a1c3c9d92f43e40.zip | |
Rollup merge of #31999 - bluss:fundamental-raw-ptr, r=eddyb
Use raw pointer casts for slice, str's .as_ptr() We can now use raw pointer casts `*const [T] as *const T` and `*const str as *const u8` instead of .repr() for getting the pointer out of a slice.
| -rw-r--r-- | src/libcore/slice.rs | 8 | ||||
| -rw-r--r-- | src/libcore/str/mod.rs | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index afda70f4fcc..fb15533f33c 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -285,12 +285,12 @@ impl<T> SliceExt for [T] { #[inline] unsafe fn get_unchecked(&self, index: usize) -> &T { - &*(self.repr().data.offset(index as isize)) + &*(self.as_ptr().offset(index as isize)) } #[inline] fn as_ptr(&self) -> *const T { - self.repr().data + self as *const [T] as *const T } fn binary_search_by<F>(&self, mut f: F) -> Result<usize, usize> where @@ -448,12 +448,12 @@ impl<T> SliceExt for [T] { #[inline] unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T { - &mut *(self.repr().data as *mut T).offset(index as isize) + &mut *self.as_mut_ptr().offset(index as isize) } #[inline] fn as_mut_ptr(&mut self) -> *mut T { - self.repr().data as *mut T + self as *mut [T] as *mut T } #[inline] diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 4d367cfd432..a555b859291 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1894,7 +1894,7 @@ impl StrExt for str { #[inline] fn as_ptr(&self) -> *const u8 { - self.repr().data + self as *const str as *const u8 } #[inline] |
