2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2015-03-22 20:13:15 +00:00
|
|
|
|
2014-05-27 06:56:52 +00:00
|
|
|
#[repr(packed)]
|
2018-02-04 11:10:28 +00: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 13:47:53 +00:00
|
|
|
bar: u8,
|
2015-03-26 00:06:52 +00:00
|
|
|
baz: usize
|
2013-04-10 13:47:53 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 07:43:37 +00:00
|
|
|
pub fn main() {
|
2018-02-04 11:10:28 +00: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 13:47:53 +00:00
|
|
|
assert_eq!(bar, 1);
|
|
|
|
assert_eq!(baz, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|