1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
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.
13 #![warn(clippy::single_match)]
22 Some(y) => { println!("{:?}", y); }
28 // Note the missing block braces.
29 // We suggest `if let Some(y) = x { .. }` because the macro
30 // is expanded before we can do anything.
31 Some(y) => println!("{:?}", y),
37 (2...3, 7...9) => dummy(),
41 // Not linted (pattern guards used)
43 Some(y) if y == 0 => println!("{:?}", y),
47 // Not linted (no block with statements in the single arm)
49 (2...3, 7...9) => println!("{:?}", z),
50 _ => println!("nope"),
54 enum Foo { Bar, Baz(u8) }
58 fn single_match_know_enum() {
60 let y : Result<_, i8> = Ok(1i8);
72 let c = Cow::Borrowed("");
75 Cow::Borrowed(..) => dummy(),
82 Bar => println!("42"),
87 Baz(_) => println!("42"),