• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![allow(
2     dead_code,
3     non_snake_case,
4     non_camel_case_types,
5     non_upper_case_globals
6 )]
7 
8 #[repr(C)]
9 pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
10 impl<T> __BindgenUnionField<T> {
11     #[inline]
new() -> Self12     pub fn new() -> Self {
13         __BindgenUnionField(::std::marker::PhantomData)
14     }
15     #[inline]
as_ref(&self) -> &T16     pub unsafe fn as_ref(&self) -> &T {
17         ::std::mem::transmute(self)
18     }
19     #[inline]
as_mut(&mut self) -> &mut T20     pub unsafe fn as_mut(&mut self) -> &mut T {
21         ::std::mem::transmute(self)
22     }
23 }
24 impl<T> ::std::default::Default for __BindgenUnionField<T> {
25     #[inline]
default() -> Self26     fn default() -> Self {
27         Self::new()
28     }
29 }
30 impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
31     #[inline]
clone(&self) -> Self32     fn clone(&self) -> Self {
33         Self::new()
34     }
35 }
36 impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
37 impl<T> ::std::fmt::Debug for __BindgenUnionField<T> {
fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result38     fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
39         fmt.write_str("__BindgenUnionField")
40     }
41 }
42 impl<T> ::std::hash::Hash for __BindgenUnionField<T> {
hash<H: ::std::hash::Hasher>(&self, _state: &mut H)43     fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) {}
44 }
45 impl<T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
eq(&self, _other: &__BindgenUnionField<T>) -> bool46     fn eq(&self, _other: &__BindgenUnionField<T>) -> bool {
47         true
48     }
49 }
50 impl<T> ::std::cmp::Eq for __BindgenUnionField<T> {}
51 /// This should manually derive PartialEq.
52 #[repr(C)]
53 #[derive(Copy)]
54 pub struct ShouldDerivePartialEq {
55     pub a: __BindgenUnionField<[::std::os::raw::c_char; 150usize]>,
56     pub b: __BindgenUnionField<::std::os::raw::c_int>,
57     pub bindgen_union_field: [u32; 38usize],
58 }
59 #[test]
bindgen_test_layout_ShouldDerivePartialEq()60 fn bindgen_test_layout_ShouldDerivePartialEq() {
61     const UNINIT: ::std::mem::MaybeUninit<ShouldDerivePartialEq> =
62         ::std::mem::MaybeUninit::uninit();
63     let ptr = UNINIT.as_ptr();
64     assert_eq!(
65         ::std::mem::size_of::<ShouldDerivePartialEq>(),
66         152usize,
67         concat!("Size of: ", stringify!(ShouldDerivePartialEq))
68     );
69     assert_eq!(
70         ::std::mem::align_of::<ShouldDerivePartialEq>(),
71         4usize,
72         concat!("Alignment of ", stringify!(ShouldDerivePartialEq))
73     );
74     assert_eq!(
75         unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize },
76         0usize,
77         concat!(
78             "Offset of field: ",
79             stringify!(ShouldDerivePartialEq),
80             "::",
81             stringify!(a)
82         )
83     );
84     assert_eq!(
85         unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize },
86         0usize,
87         concat!(
88             "Offset of field: ",
89             stringify!(ShouldDerivePartialEq),
90             "::",
91             stringify!(b)
92         )
93     );
94 }
95 impl Clone for ShouldDerivePartialEq {
clone(&self) -> Self96     fn clone(&self) -> Self {
97         *self
98     }
99 }
100 impl Default for ShouldDerivePartialEq {
default() -> Self101     fn default() -> Self {
102         unsafe {
103             let mut s: Self = ::std::mem::uninitialized();
104             ::std::ptr::write_bytes(&mut s, 0, 1);
105             s
106         }
107     }
108 }
109 impl ::std::cmp::PartialEq for ShouldDerivePartialEq {
eq(&self, other: &ShouldDerivePartialEq) -> bool110     fn eq(&self, other: &ShouldDerivePartialEq) -> bool {
111         &self.bindgen_union_field[..] == &other.bindgen_union_field[..]
112     }
113 }
114