diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2015-02-01 21:53:25 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2015-02-05 13:45:01 -0500 |
| commit | 17bc7d8d5be3be9674d702ccad2fa88c487d23b0 (patch) | |
| tree | 325defba0f55b48273cd3f0814fe6c083dee5d41 /src/libstd/ffi | |
| parent | 2c05354211b04a52cc66a0b8ad8b2225eaf9e972 (diff) | |
| download | rust-17bc7d8d5be3be9674d702ccad2fa88c487d23b0.tar.gz rust-17bc7d8d5be3be9674d702ccad2fa88c487d23b0.zip | |
cleanup: replace `as[_mut]_slice()` calls with deref coercions
Diffstat (limited to 'src/libstd/ffi')
| -rw-r--r-- | src/libstd/ffi/c_str.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 2e55c007b55..4c8735bd4ad 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -13,7 +13,7 @@ use iter::IteratorExt; use libc; use mem; use ops::Deref; -use slice::{self, SliceExt, AsSlice}; +use slice::{self, SliceExt}; use string::String; use vec::Vec; @@ -96,12 +96,12 @@ impl CString { /// Create a view into this C string which includes the trailing nul /// terminator at the end of the string. - pub fn as_slice_with_nul(&self) -> &[libc::c_char] { self.inner.as_slice() } + pub fn as_slice_with_nul(&self) -> &[libc::c_char] { &self.inner } /// Similar to the `as_slice` method, but returns a `u8` slice instead of a /// `libc::c_char` slice. pub fn as_bytes(&self) -> &[u8] { - unsafe { mem::transmute(self.as_slice()) } + unsafe { mem::transmute(&**self) } } /// Equivalent to `as_slice_with_nul` except that the type returned is a @@ -197,7 +197,7 @@ mod tests { assert_eq!(s.as_bytes(), b"1234"); assert_eq!(s.as_bytes_with_nul(), b"1234\0"); unsafe { - assert_eq!(s.as_slice(), + assert_eq!(&*s, mem::transmute::<_, &[libc::c_char]>(b"1234")); assert_eq!(s.as_slice_with_nul(), mem::transmute::<_, &[libc::c_char]>(b"1234\0")); |
