2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(unused_assignments)]
|
|
|
|
#![allow(unused_variables)]
|
2018-08-31 08:02:01 -05:00
|
|
|
#![allow(non_shorthand_field_patterns)]
|
2015-03-22 15:13:15 -05:00
|
|
|
|
2013-12-06 02:15:02 -06:00
|
|
|
pub fn main() {
|
2015-03-25 19:06:52 -05:00
|
|
|
struct Foo { x: isize, y: isize }
|
2013-12-06 02:15:02 -06:00
|
|
|
let mut f = Foo { x: 10, y: 0 };
|
|
|
|
match f {
|
|
|
|
Foo { ref mut x, .. } => *x = 11,
|
|
|
|
}
|
|
|
|
match f {
|
|
|
|
Foo { ref x, ref y } => {
|
|
|
|
assert_eq!(f.x, 11);
|
|
|
|
assert_eq!(f.y, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
match f {
|
|
|
|
Foo { mut x, y: ref mut y } => {
|
|
|
|
x = 12;
|
|
|
|
*y = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert_eq!(f.x, 11);
|
|
|
|
assert_eq!(f.y, 1);
|
|
|
|
}
|