summaryrefslogtreecommitdiffstats
path: root/src/test/ui/binding/match-ref-binding-mut.rs
blob: d7afd61bc8e325e16dfc6a16edc9a99938fc1a4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 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);
}