2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(unused_assignments)]
|
|
|
|
#![allow(unused_variables)]
|
2018-08-31 13:02:01 +00:00
|
|
|
#![allow(non_shorthand_field_patterns)]
|
2015-03-22 20:13:15 +00:00
|
|
|
|
2013-12-06 08:15:02 +00:00
|
|
|
pub fn main() {
|
2015-03-26 00:06:52 +00:00
|
|
|
struct Foo { x: isize, y: isize }
|
2013-12-06 08:15:02 +00: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);
|
|
|
|
}
|