File tree 1 file changed +4
-6
lines changed
1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 5
5
//!
6
6
//! Unsafe helpers for working with raw TraitObjects.
7
7
8
- use std:: mem;
9
-
10
8
/// Get the data pointer from this trait object.
11
9
///
12
10
/// Highly unsafe, as there is no information about the type of the data.
13
11
pub unsafe fn data < T : ?Sized > ( val : * const T ) -> * const ( ) {
14
- * mem :: transmute :: < * const * const T , * const * const ( ) > ( & val )
12
+ val as * const ( )
15
13
}
16
14
17
15
/// Get the data pointer from this trait object, mutably.
18
16
///
19
17
/// Highly unsafe, as there is no information about the type of the data.
20
- pub unsafe fn data_mut < T : ?Sized > ( mut val : * mut T ) -> * mut ( ) {
21
- * mem :: transmute :: < * mut * mut T , * mut * mut ( ) > ( & mut val )
18
+ pub unsafe fn data_mut < T : ?Sized > ( val : * mut T ) -> * mut ( ) {
19
+ val as * mut ( )
22
20
}
23
21
24
22
#[ test]
25
23
fn test_simple ( ) {
26
24
let x = & 7 as & Send ;
27
- unsafe { assert ! ( & 7 == mem:: transmute:: <_, & i32 >( data( x) ) ) } ;
25
+ unsafe { assert ! ( & 7 == std :: mem:: transmute:: <_, & i32 >( data( x) ) ) } ;
28
26
}
29
27
30
28
/// A trait implemented for all trait objects.
You can’t perform that action at this time.
0 commit comments