@@ -32,7 +32,6 @@ use char;
32
32
use fmt;
33
33
use hash:: { Hash , Hasher } ;
34
34
use iter:: FromIterator ;
35
- use mem;
36
35
use ops;
37
36
use rc:: Rc ;
38
37
use slice;
@@ -366,12 +365,12 @@ impl Wtf8Buf {
366
365
/// Converts this `Wtf8Buf` into a boxed `Wtf8`.
367
366
#[ inline]
368
367
pub fn into_box ( self ) -> Box < Wtf8 > {
369
- unsafe { mem :: transmute ( self . bytes . into_boxed_slice ( ) ) }
368
+ unsafe { Box :: from_raw ( Box :: into_raw ( self . bytes . into_boxed_slice ( ) ) as * mut Wtf8 ) }
370
369
}
371
370
372
371
/// Converts a `Box<Wtf8>` into a `Wtf8Buf`.
373
372
pub fn from_box ( boxed : Box < Wtf8 > ) -> Wtf8Buf {
374
- let bytes: Box < [ u8 ] > = unsafe { mem :: transmute ( boxed) } ;
373
+ let bytes: Box < [ u8 ] > = unsafe { Box :: from_raw ( Box :: into_raw ( boxed) as * mut [ u8 ] ) } ;
375
374
Wtf8Buf { bytes : bytes. into_vec ( ) }
376
375
}
377
376
}
@@ -493,7 +492,7 @@ impl Wtf8 {
493
492
/// marked unsafe.
494
493
#[ inline]
495
494
unsafe fn from_bytes_unchecked ( value : & [ u8 ] ) -> & Wtf8 {
496
- mem :: transmute ( value)
495
+ & * ( value as * const _ as * const Wtf8 )
497
496
}
498
497
499
498
/// Creates a mutable WTF-8 slice from a mutable WTF-8 byte slice.
@@ -502,7 +501,7 @@ impl Wtf8 {
502
501
/// marked unsafe.
503
502
#[ inline]
504
503
unsafe fn from_mut_bytes_unchecked ( value : & mut [ u8 ] ) -> & mut Wtf8 {
505
- mem :: transmute ( value)
504
+ & mut * ( value as * mut _ as * mut Wtf8 )
506
505
}
507
506
508
507
/// Returns the length, in WTF-8 bytes.
@@ -651,13 +650,13 @@ impl Wtf8 {
651
650
#[ inline]
652
651
pub fn into_box ( & self ) -> Box < Wtf8 > {
653
652
let boxed: Box < [ u8 ] > = self . bytes . into ( ) ;
654
- unsafe { mem :: transmute ( boxed) }
653
+ unsafe { Box :: from_raw ( Box :: into_raw ( boxed) as * mut Wtf8 ) }
655
654
}
656
655
657
656
/// Creates a boxed, empty `Wtf8`.
658
657
pub fn empty_box ( ) -> Box < Wtf8 > {
659
658
let boxed: Box < [ u8 ] > = Default :: default ( ) ;
660
- unsafe { mem :: transmute ( boxed) }
659
+ unsafe { Box :: from_raw ( Box :: into_raw ( boxed) as * mut Wtf8 ) }
661
660
}
662
661
663
662
#[ inline]
0 commit comments