1 #![allow( 2 dead_code, 3 non_snake_case, 4 non_camel_case_types, 5 non_upper_case_globals 6 )] 7 8 #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] 9 pub mod root { 10 #[repr(C)] 11 pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); 12 impl<T> __BindgenUnionField<T> { 13 #[inline] new() -> Self14 pub fn new() -> Self { 15 __BindgenUnionField(::std::marker::PhantomData) 16 } 17 #[inline] as_ref(&self) -> &T18 pub unsafe fn as_ref(&self) -> &T { 19 ::std::mem::transmute(self) 20 } 21 #[inline] as_mut(&mut self) -> &mut T22 pub unsafe fn as_mut(&mut self) -> &mut T { 23 ::std::mem::transmute(self) 24 } 25 } 26 impl<T> ::std::default::Default for __BindgenUnionField<T> { 27 #[inline] default() -> Self28 fn default() -> Self { 29 Self::new() 30 } 31 } 32 impl<T> ::std::clone::Clone for __BindgenUnionField<T> { 33 #[inline] clone(&self) -> Self34 fn clone(&self) -> Self { 35 Self::new() 36 } 37 } 38 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {} 39 impl<T> ::std::fmt::Debug for __BindgenUnionField<T> { fmt( &self, fmt: &mut ::std::fmt::Formatter<'_>, ) -> ::std::fmt::Result40 fn fmt( 41 &self, 42 fmt: &mut ::std::fmt::Formatter<'_>, 43 ) -> ::std::fmt::Result { 44 fmt.write_str("__BindgenUnionField") 45 } 46 } 47 impl<T> ::std::hash::Hash for __BindgenUnionField<T> { hash<H: ::std::hash::Hasher>(&self, _state: &mut H)48 fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) {} 49 } 50 impl<T> ::std::cmp::PartialEq for __BindgenUnionField<T> { eq(&self, _other: &__BindgenUnionField<T>) -> bool51 fn eq(&self, _other: &__BindgenUnionField<T>) -> bool { 52 true 53 } 54 } 55 impl<T> ::std::cmp::Eq for __BindgenUnionField<T> {} 56 #[allow(unused_imports)] 57 use self::super::root; 58 pub mod foo { 59 #[allow(unused_imports)] 60 use self::super::super::root; 61 #[repr(C)] 62 #[derive(Debug, Default, Copy)] 63 pub struct Bar { 64 pub foo: root::__BindgenUnionField<::std::os::raw::c_int>, 65 pub bar: root::__BindgenUnionField<::std::os::raw::c_int>, 66 pub bindgen_union_field: u32, 67 } 68 #[test] bindgen_test_layout_Bar()69 fn bindgen_test_layout_Bar() { 70 const UNINIT: ::std::mem::MaybeUninit<Bar> = 71 ::std::mem::MaybeUninit::uninit(); 72 let ptr = UNINIT.as_ptr(); 73 assert_eq!( 74 ::std::mem::size_of::<Bar>(), 75 4usize, 76 concat!("Size of: ", stringify!(Bar)) 77 ); 78 assert_eq!( 79 ::std::mem::align_of::<Bar>(), 80 4usize, 81 concat!("Alignment of ", stringify!(Bar)) 82 ); 83 assert_eq!( 84 unsafe { 85 ::std::ptr::addr_of!((*ptr).foo) as usize - ptr as usize 86 }, 87 0usize, 88 concat!( 89 "Offset of field: ", 90 stringify!(Bar), 91 "::", 92 stringify!(foo) 93 ) 94 ); 95 assert_eq!( 96 unsafe { 97 ::std::ptr::addr_of!((*ptr).bar) as usize - ptr as usize 98 }, 99 0usize, 100 concat!( 101 "Offset of field: ", 102 stringify!(Bar), 103 "::", 104 stringify!(bar) 105 ) 106 ); 107 } 108 impl Clone for Bar { clone(&self) -> Self109 fn clone(&self) -> Self { 110 *self 111 } 112 } 113 } 114 } 115