rust/tests/ui/binding/match-ref-binding-mut.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
269 B
Rust
Raw Normal View History

// run-pass
#![allow(non_shorthand_field_patterns)]
struct Rec {
f: isize
}
fn destructure(x: &mut Rec) {
2012-08-06 18:13:52 -05:00
match *x {
Rec {f: ref mut f} => *f += 1
}
}
pub fn main() {
let mut v = Rec {f: 22};
destructure(&mut v);
assert_eq!(v.f, 23);
2012-08-06 18:13:52 -05:00
}