2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2018-08-31 13:02:01 +00:00
|
|
|
#![allow(non_shorthand_field_patterns)]
|
2015-03-22 20:13:15 +00:00
|
|
|
|
2013-01-26 06:46:32 +00:00
|
|
|
struct Rec {
|
2015-03-26 00:06:52 +00:00
|
|
|
f: isize
|
2013-01-26 06:46:32 +00:00
|
|
|
}
|
2012-08-06 14:20:23 +00:00
|
|
|
|
2013-01-26 06:46:32 +00:00
|
|
|
fn destructure(x: &mut Rec) {
|
2012-08-06 23:13:52 +00:00
|
|
|
match *x {
|
2013-01-26 06:46:32 +00:00
|
|
|
Rec {f: ref mut f} => *f += 1
|
2012-08-06 14:20:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2013-01-26 06:46:32 +00:00
|
|
|
let mut v = Rec {f: 22};
|
2012-08-06 14:20:23 +00:00
|
|
|
destructure(&mut v);
|
2013-05-19 02:02:45 +00:00
|
|
|
assert_eq!(v.f, 23);
|
2012-08-06 23:13:52 +00:00
|
|
|
}
|