diff options
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/common/wtf8.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 6c17f9910ac..4c0b26f8649 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -29,7 +29,6 @@ use core::prelude::*; use core::char::{encode_utf8_raw, encode_utf16_raw}; use core::str::{char_range_at_raw, next_code_point}; -use core::raw::Slice as RawSlice; use ascii::*; use borrow::Cow; @@ -214,10 +213,10 @@ impl Wtf8Buf { unsafe { // Attempt to not use an intermediate buffer by just pushing bytes // directly onto this string. - let slice = RawSlice { - data: self.bytes.as_ptr().offset(cur_len as int), - len: 4, - }; + let slice = slice::from_raw_parts_mut( + self.bytes.as_mut_ptr().offset(cur_len as int), + 4 + ); let used = encode_utf8_raw(code_point.value, mem::transmute(slice)) .unwrap_or(0); self.bytes.set_len(cur_len + used); @@ -725,10 +724,11 @@ pub fn is_code_point_boundary(slice: &Wtf8, index: uint) -> bool { /// Copied from core::str::raw::slice_unchecked #[inline] pub unsafe fn slice_unchecked(s: &Wtf8, begin: uint, end: uint) -> &Wtf8 { - mem::transmute(RawSlice { - data: s.bytes.as_ptr().offset(begin as int), - len: end - begin, - }) + // memory layout of an &[u8] and &Wtf8 are the same + mem::transmute(slice::from_raw_parts( + s.bytes.as_ptr().offset(begin as int), + end - begin + )) } /// Copied from core::str::raw::slice_error_fail |
