• 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 /// Since builtin `Clone` impls were introduced in Rust 1.21 this struct
9 /// should impl `Clone` "manually".
10 #[repr(C)]
11 #[derive(Copy)]
12 pub struct ShouldImplClone {
13     pub large: [::std::os::raw::c_int; 33usize],
14 }
15 #[test]
bindgen_test_layout_ShouldImplClone()16 fn bindgen_test_layout_ShouldImplClone() {
17     const UNINIT: ::std::mem::MaybeUninit<ShouldImplClone> =
18         ::std::mem::MaybeUninit::uninit();
19     let ptr = UNINIT.as_ptr();
20     assert_eq!(
21         ::std::mem::size_of::<ShouldImplClone>(),
22         132usize,
23         concat!("Size of: ", stringify!(ShouldImplClone))
24     );
25     assert_eq!(
26         ::std::mem::align_of::<ShouldImplClone>(),
27         4usize,
28         concat!("Alignment of ", stringify!(ShouldImplClone))
29     );
30     assert_eq!(
31         unsafe { ::std::ptr::addr_of!((*ptr).large) as usize - ptr as usize },
32         0usize,
33         concat!(
34             "Offset of field: ",
35             stringify!(ShouldImplClone),
36             "::",
37             stringify!(large)
38         )
39     );
40 }
41 impl Clone for ShouldImplClone {
clone(&self) -> Self42     fn clone(&self) -> Self {
43         *self
44     }
45 }
46 impl Default for ShouldImplClone {
default() -> Self47     fn default() -> Self {
48         unsafe {
49             let mut s: Self = ::std::mem::uninitialized();
50             ::std::ptr::write_bytes(&mut s, 0, 1);
51             s
52         }
53     }
54 }
55