]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/rfc-2005-default-binding-mode/enum.rs
a7b3db021b021a428a45a6571c0758b0277327e6
[rust.git] / src / test / run-pass / rfc-2005-default-binding-mode / enum.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(match_default_bindings)]
12
13 enum Wrapper {
14     Wrap(i32),
15 }
16
17 use Wrapper::Wrap;
18
19 pub fn main() {
20     let Wrap(x) = &Wrap(3);
21     println!("{}", *x);
22
23     let Wrap(x) = &mut Wrap(3);
24     println!("{}", *x);
25
26     if let Some(x) = &Some(3) {
27         println!("{}", *x);
28     } else {
29         panic!();
30     }
31
32     if let Some(x) = &mut Some(3) {
33         println!("{}", *x);
34     } else {
35         panic!();
36     }
37
38     if let Some(x) = &mut Some(3) {
39         *x += 1;
40     } else {
41         panic!();
42     }
43
44     while let Some(x) = &Some(3) {
45         println!("{}", *x);
46         break;
47     }
48     while let Some(x) = &mut Some(3) {
49         println!("{}", *x);
50         break;
51     }
52     while let Some(x) = &mut Some(3) {
53         *x += 1;
54         break;
55     }
56 }