mirror of
https://github.com/rust-lang/rust
synced 2024-11-05 20:45:15 +00:00
18 lines
270 B
Rust
18 lines
270 B
Rust
//@ run-pass
|
|
#![allow(non_shorthand_field_patterns)]
|
|
|
|
struct Rec {
|
|
f: isize
|
|
}
|
|
|
|
fn destructure(x: &mut Rec) {
|
|
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);
|
|
}
|