File tree 2 files changed +4
-8
lines changed
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> {
528
528
#[ stable( feature = "boxed_str_conv" , since = "1.19.0" ) ]
529
529
impl From < Box < str > > for Box < [ u8 ] > {
530
530
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 ] ) }
534
532
}
535
533
}
536
534
Original file line number Diff line number Diff line change @@ -2047,10 +2047,8 @@ impl str {
2047
2047
/// ```
2048
2048
#[ stable( feature = "box_str" , since = "1.4.0" ) ]
2049
2049
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 ( ) ) }
2054
2052
}
2055
2053
2056
2054
/// Create a [`String`] by repeating a string `n` times.
@@ -2087,5 +2085,5 @@ impl str {
2087
2085
/// ```
2088
2086
#[ stable( feature = "str_box_extras" , since = "1.20.0" ) ]
2089
2087
pub 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 )
2091
2089
}
You can’t perform that action at this time.
0 commit comments