@@ -14,25 +14,6 @@ use mem;
14
14
use intrinsics;
15
15
use ptr:: copy_nonoverlapping_memory;
16
16
17
- /// Casts the value at `src` to U. The two types must have the same length.
18
- #[ inline]
19
- pub unsafe fn transmute_copy < T , U > ( src : & T ) -> U {
20
- let mut dest: U = mem:: uninit ( ) ;
21
- let dest_ptr: * mut u8 = transmute ( & mut dest) ;
22
- let src_ptr: * u8 = transmute ( src) ;
23
- copy_nonoverlapping_memory ( dest_ptr, src_ptr, mem:: size_of :: < U > ( ) ) ;
24
- dest
25
- }
26
-
27
- /**
28
- * Move a thing into the void
29
- *
30
- * The forget function will take ownership of the provided value but neglect
31
- * to run any required cleanup or memory-management operations on it.
32
- */
33
- #[ inline]
34
- pub unsafe fn forget < T > ( thing : T ) { intrinsics:: forget ( thing) ; }
35
-
36
17
/**
37
18
* Transform a value of one type into a value of another type.
38
19
* Both types must have the same size and alignment.
@@ -51,6 +32,25 @@ pub unsafe fn transmute<L, G>(thing: L) -> G {
51
32
intrinsics:: transmute ( thing)
52
33
}
53
34
35
+ /**
36
+ * Move a thing into the void
37
+ *
38
+ * The forget function will take ownership of the provided value but neglect
39
+ * to run any required cleanup or memory-management operations on it.
40
+ */
41
+ #[ inline]
42
+ pub unsafe fn forget < T > ( thing : T ) { intrinsics:: forget ( thing) ; }
43
+
44
+ /// Casts the value at `src` to U. The two types must have the same length.
45
+ #[ inline]
46
+ pub unsafe fn transmute_copy < T , U > ( src : & T ) -> U {
47
+ let mut dest: U = mem:: uninit ( ) ;
48
+ let dest_ptr: * mut u8 = transmute ( & mut dest) ;
49
+ let src_ptr: * u8 = transmute ( src) ;
50
+ copy_nonoverlapping_memory ( dest_ptr, src_ptr, mem:: size_of :: < U > ( ) ) ;
51
+ dest
52
+ }
53
+
54
54
/// Coerce an immutable reference to be mutable.
55
55
#[ inline]
56
56
#[ deprecated="casting &T to &mut T is undefined behaviour: use Cell<T>, RefCell<T> or Unsafe<T>" ]
0 commit comments