2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2015-03-22 15:13:15 -05:00
|
|
|
|
2014-05-27 01:56:52 -05:00
|
|
|
#[repr(packed)]
|
2018-02-04 05:10:28 -06:00
|
|
|
struct Foo1 {
|
|
|
|
bar: u8,
|
|
|
|
baz: usize
|
|
|
|
}
|
|
|
|
|
|
|
|
#[repr(packed(2))]
|
|
|
|
struct Foo2 {
|
|
|
|
bar: u8,
|
|
|
|
baz: usize
|
|
|
|
}
|
|
|
|
|
|
|
|
#[repr(C, packed(4))]
|
|
|
|
struct Foo4C {
|
2013-04-10 08:47:53 -05:00
|
|
|
bar: u8,
|
2015-03-25 19:06:52 -05:00
|
|
|
baz: usize
|
2013-04-10 08:47:53 -05:00
|
|
|
}
|
|
|
|
|
2013-09-25 02:43:37 -05:00
|
|
|
pub fn main() {
|
2018-02-04 05:10:28 -06:00
|
|
|
let foo1 = Foo1 { bar: 1, baz: 2 };
|
|
|
|
match foo1 {
|
|
|
|
Foo1 {bar, baz} => {
|
|
|
|
assert_eq!(bar, 1);
|
|
|
|
assert_eq!(baz, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let foo2 = Foo2 { bar: 1, baz: 2 };
|
|
|
|
match foo2 {
|
|
|
|
Foo2 {bar, baz} => {
|
|
|
|
assert_eq!(bar, 1);
|
|
|
|
assert_eq!(baz, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let foo4 = Foo4C { bar: 1, baz: 2 };
|
|
|
|
match foo4 {
|
|
|
|
Foo4C {bar, baz} => {
|
2013-04-10 08:47:53 -05:00
|
|
|
assert_eq!(bar, 1);
|
|
|
|
assert_eq!(baz, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|