File tree Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -528,9 +528,7 @@ impl<'a> From<&'a str> for Box<str> {
528528#[ stable( feature = "boxed_str_conv" , since = "1.19.0" ) ]
529529impl From < Box < str > > for Box < [ u8 ] > {
530530 fn from ( s : Box < str > ) -> Self {
531- unsafe {
532- mem:: transmute ( s)
533- }
531+ unsafe { Box :: from_raw ( Box :: into_raw ( s) as * mut [ u8 ] ) }
534532 }
535533}
536534
Original file line number Diff line number Diff line change @@ -2047,10 +2047,8 @@ impl str {
20472047 /// ```
20482048 #[ stable( feature = "box_str" , since = "1.4.0" ) ]
20492049 pub fn into_string ( self : Box < str > ) -> String {
2050- unsafe {
2051- let slice = mem:: transmute :: < Box < str > , Box < [ u8 ] > > ( self ) ;
2052- String :: from_utf8_unchecked ( slice. into_vec ( ) )
2053- }
2050+ let slice = Box :: < [ u8 ] > :: from ( self ) ;
2051+ unsafe { String :: from_utf8_unchecked ( slice. into_vec ( ) ) }
20542052 }
20552053
20562054 /// Create a [`String`] by repeating a string `n` times.
@@ -2087,5 +2085,5 @@ impl str {
20872085/// ```
20882086#[ stable( feature = "str_box_extras" , since = "1.20.0" ) ]
20892087pub unsafe fn from_boxed_utf8_unchecked ( v : Box < [ u8 ] > ) -> Box < str > {
2090- mem :: transmute ( v )
2088+ Box :: from_raw ( Box :: into_raw ( v ) as * mut str )
20912089}
You can’t perform that action at this time.
0 commit comments