3 #![feature(const_size_of_val, const_align_of_val)]
21 const FOO: Foo = Foo(4);
22 const BAR: Bar = Bar { _x: 4, _y: 1, _z: 2 };
23 const UGH: Ugh = Ugh { _a: [0; 3] };
25 const SIZE_OF_FOO: usize = mem::size_of_val(&FOO);
26 const SIZE_OF_BAR: usize = mem::size_of_val(&BAR);
27 const SIZE_OF_UGH: usize = mem::size_of_val(&UGH);
29 const ALIGN_OF_FOO: usize = mem::align_of_val(&FOO);
30 const ALIGN_OF_BAR: usize = mem::align_of_val(&BAR);
31 const ALIGN_OF_UGH: usize = mem::align_of_val(&UGH);
33 const SIZE_OF_SLICE: usize = mem::size_of_val("foobar".as_bytes());
36 assert_eq!(SIZE_OF_FOO, mem::size_of::<Foo>());
37 assert_eq!(SIZE_OF_BAR, mem::size_of::<Bar>());
38 assert_eq!(SIZE_OF_UGH, mem::size_of::<Ugh>());
40 assert_eq!(ALIGN_OF_FOO, mem::align_of::<Foo>());
41 assert_eq!(ALIGN_OF_BAR, mem::align_of::<Bar>());
42 assert_eq!(ALIGN_OF_UGH, mem::align_of::<Ugh>());
44 assert_eq!(SIZE_OF_SLICE, "foobar".len());