]> git.lizzy.rs Git - rust.git/blob - tests/ui/match_bool.rs
Merge pull request #3269 from rust-lang-nursery/relicense
[rust.git] / tests / ui / match_bool.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10
11 fn match_bool() {
12     let test: bool = true;
13
14     match test {
15         true => 0,
16         false => 42,
17     };
18
19     let option = 1;
20     match option == 1 {
21         true => 1,
22         false => 0,
23     };
24
25     match test {
26         true => (),
27         false => { println!("Noooo!"); }
28     };
29
30     match test {
31         false => { println!("Noooo!"); }
32         _ => (),
33     };
34
35     match test && test {
36         false => { println!("Noooo!"); }
37         _ => (),
38     };
39
40     match test {
41         false => { println!("Noooo!"); }
42         true => { println!("Yes!"); }
43     };
44
45     // Not linted
46     match option {
47         1 ... 10 => 1,
48         11 ... 20 => 2,
49         _ => 3,
50     };
51 }
52
53 fn main() {
54 }