]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/rfc-2005-default-binding-mode/enum.rs
4755fc37ef3470fd34212c5d993f0682a5a76c03
[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 enum Wrapper {
12     Wrap(i32),
13 }
14
15 use Wrapper::Wrap;
16
17 pub fn main() {
18     let Wrap(x) = &Wrap(3);
19     println!("{}", *x);
20
21     let Wrap(x) = &mut Wrap(3);
22     println!("{}", *x);
23
24     if let Some(x) = &Some(3) {
25         println!("{}", *x);
26     } else {
27         panic!();
28     }
29
30     if let Some(x) = &mut Some(3) {
31         println!("{}", *x);
32     } else {
33         panic!();
34     }
35
36     if let Some(x) = &mut Some(3) {
37         *x += 1;
38     } else {
39         panic!();
40     }
41
42     while let Some(x) = &Some(3) {
43         println!("{}", *x);
44         break;
45     }
46     while let Some(x) = &mut Some(3) {
47         println!("{}", *x);
48         break;
49     }
50     while let Some(x) = &mut Some(3) {
51         *x += 1;
52         break;
53     }
54 }