We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a09a60c commit e71470cCopy full SHA for e71470c
src/macros.rs
@@ -29,17 +29,8 @@ macro_rules! EXTERN {
29
macro_rules! FIELD_OFFSET {
30
($_type:ty, $field:ident$(.$cfields:ident)*) => {
31
unsafe {
32
- union Transmuter<T: 'static> {
33
- p: *const T,
34
- r: &'static T,
35
- i: usize,
36
- }
37
- #[allow(unaligned_references)]
38
- Transmuter {
39
- r: &(&Transmuter {
40
- p: $crate::_core::ptr::null::<$_type>()
41
- }.r).$field$(.$cfields)*
42
- }.i
+ let base = ::core::mem::MaybeUninit::<$_type>::uninit().as_ptr();
+ ::core::ptr::addr_of!((*base).$field$(.$cfields)*) as usize - base as usize
43
}
44
};
45
0 commit comments