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