5
5
6
6
extern crate core;
7
7
8
+ #[ repr( C ) ]
9
+ pub struct __BindgenUnionField < T > ( :: core:: marker:: PhantomData < T > ) ;
10
+ impl < T > __BindgenUnionField < T > {
11
+ #[ inline]
12
+ pub fn new ( ) -> Self { __BindgenUnionField ( :: core:: marker:: PhantomData ) }
13
+ #[ inline]
14
+ pub unsafe fn as_ref ( & self ) -> & T { :: core:: mem:: transmute ( self ) }
15
+ #[ inline]
16
+ pub unsafe fn as_mut ( & mut self ) -> & mut T { :: core:: mem:: transmute ( self ) }
17
+ }
18
+ impl < T > :: core:: default:: Default for __BindgenUnionField < T > {
19
+ #[ inline]
20
+ fn default ( ) -> Self { Self :: new ( ) }
21
+ }
22
+ impl < T > :: core:: clone:: Clone for __BindgenUnionField < T > {
23
+ #[ inline]
24
+ fn clone ( & self ) -> Self { Self :: new ( ) }
25
+ }
26
+ impl < T > :: core:: marker:: Copy for __BindgenUnionField < T > { }
27
+ impl < T > :: core:: fmt:: Debug for __BindgenUnionField < T > {
28
+ fn fmt ( & self , fmt : & mut :: core:: fmt:: Formatter ) -> :: core:: fmt:: Result {
29
+ fmt. write_str ( "__BindgenUnionField" )
30
+ }
31
+ }
8
32
#[ repr( C ) ]
9
33
#[ derive( Debug , Copy ) ]
10
34
pub struct foo {
11
- pub a : :: std :: os:: raw:: c_int ,
12
- pub b : :: std :: os:: raw:: c_int ,
13
- pub bar : * mut :: std :: os:: raw:: c_void ,
35
+ pub a : :: core :: os:: raw:: c_int ,
36
+ pub b : :: core :: os:: raw:: c_int ,
37
+ pub bar : * mut :: core :: os:: raw:: c_void ,
14
38
}
15
39
#[ test]
16
40
fn bindgen_test_layout_foo ( ) {
@@ -29,5 +53,30 @@ fn bindgen_test_layout_foo() {
29
53
impl Clone for foo {
30
54
fn clone ( & self ) -> Self { * self }
31
55
}
56
+ #[ repr( C ) ]
57
+ #[ derive( Debug , Copy ) ]
58
+ pub struct _bindgen_ty_1 {
59
+ pub bar : __BindgenUnionField < :: core:: os:: raw:: c_int > ,
60
+ pub baz : __BindgenUnionField < :: core:: os:: raw:: c_long > ,
61
+ pub bindgen_union_field : u64 ,
62
+ }
63
+ #[ test]
64
+ fn bindgen_test_layout__bindgen_ty_1 ( ) {
65
+ assert_eq ! ( :: core:: mem:: size_of:: <_bindgen_ty_1>( ) , 8usize ) ;
66
+ assert_eq ! ( :: core:: mem:: align_of:: <_bindgen_ty_1>( ) , 8usize ) ;
67
+ assert_eq ! ( unsafe {
68
+ & ( * ( 0 as * const _bindgen_ty_1 ) ) . bar as * const _ as
69
+ usize } , 0usize ) ;
70
+ assert_eq ! ( unsafe {
71
+ & ( * ( 0 as * const _bindgen_ty_1 ) ) . baz as * const _ as
72
+ usize } , 0usize ) ;
73
+ }
74
+ impl Clone for _bindgen_ty_1 {
75
+ fn clone ( & self ) -> Self { * self }
76
+ }
77
+ extern "C" {
78
+ #[ link_name = "bazz" ]
79
+ pub static mut bazz: _bindgen_ty_1 ;
80
+ }
32
81
pub type fooFunction =
33
- :: core:: option:: Option < unsafe extern "C" fn ( bar : :: std :: os:: raw:: c_int ) > ;
82
+ :: core:: option:: Option < unsafe extern "C" fn ( bar : :: core :: os:: raw:: c_int ) > ;
0 commit comments