diff options
| author | Nikolai Vazquez <nvazquez1297@gmail.com> | 2017-09-27 14:56:20 -0400 |
|---|---|---|
| committer | Nikolai Vazquez <nvazquez1297@gmail.com> | 2017-09-27 14:56:20 -0400 |
| commit | 36d663fcfc7a219f034ecdd219f03517e17db62d (patch) | |
| tree | 4d52665393e9a07ab1cb96b81275e74017f4ef0d /src/liballoc/str.rs | |
| parent | 930d3b17dd91b6564cf535ac717c688db757be5d (diff) | |
| download | rust-36d663fcfc7a219f034ecdd219f03517e17db62d.tar.gz rust-36d663fcfc7a219f034ecdd219f03517e17db62d.zip | |
Remove mem::transmute used in Box<str> conversions
Diffstat (limited to 'src/liballoc/str.rs')
| -rw-r--r-- | src/liballoc/str.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index 62b5f13675c..830128f2b9f 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -2047,10 +2047,8 @@ impl str { /// ``` #[stable(feature = "box_str", since = "1.4.0")] pub fn into_string(self: Box<str>) -> String { - unsafe { - let slice = mem::transmute::<Box<str>, Box<[u8]>>(self); - String::from_utf8_unchecked(slice.into_vec()) - } + let slice = Box::<[u8]>::from(self); + unsafe { String::from_utf8_unchecked(slice.into_vec()) } } /// Create a [`String`] by repeating a string `n` times. @@ -2087,5 +2085,5 @@ impl str { /// ``` #[stable(feature = "str_box_extras", since = "1.20.0")] pub unsafe fn from_boxed_utf8_unchecked(v: Box<[u8]>) -> Box<str> { - mem::transmute(v) + Box::from_raw(Box::into_raw(v) as *mut str) } |
