about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorUlrik Sverdrup <bluss@users.noreply.github.com>2016-03-01 20:21:55 +0100
committerUlrik Sverdrup <bluss@users.noreply.github.com>2016-03-01 22:30:18 +0100
commit63c4065af00a61aef24153a1d3dde76013f433bb (patch)
tree705c7f7c748b7dbe274c3906cc5c068520bf3b8d /src
parent09130044ce7429beb95742afa7fd371960dbe607 (diff)
downloadrust-63c4065af00a61aef24153a1d3dde76013f433bb.tar.gz
rust-63c4065af00a61aef24153a1d3dde76013f433bb.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/libcore/slice.rs8
-rw-r--r--src/libcore/str/mod.rs2
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]