mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
wildcard_match_arm: format test.
This commit is contained in:
parent
6bc4416b2b
commit
c7ae44c0e2
1 changed files with 26 additions and 26 deletions
|
@ -2,35 +2,35 @@
|
|||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
enum Color {
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Rgb(u8, u8, u8),
|
||||
Cyan,
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Rgb(u8, u8, u8),
|
||||
Cyan,
|
||||
}
|
||||
|
||||
impl Color {
|
||||
fn is_monochrome(self) -> bool {
|
||||
match self {
|
||||
Color::Red | Color::Green | Color::Blue => true,
|
||||
Color::Rgb(r, g, b) => r | g == 0 || r | b == 0 || g | b == 0,
|
||||
Color::Cyan => false,
|
||||
}
|
||||
}
|
||||
fn is_monochrome(self) -> bool {
|
||||
match self {
|
||||
Color::Red | Color::Green | Color::Blue => true,
|
||||
Color::Rgb(r, g, b) => r | g == 0 || r | b == 0 || g | b == 0,
|
||||
Color::Cyan => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let color = Color::Rgb(0, 0, 127);
|
||||
match color {
|
||||
Color::Red => println!("Red"),
|
||||
_ => eprintln!("Not red"),
|
||||
};
|
||||
match color {
|
||||
Color::Red => {},
|
||||
Color::Green => {},
|
||||
Color::Blue => {},
|
||||
Color::Cyan => {},
|
||||
c if c.is_monochrome() => {},
|
||||
Color::Rgb(_, _, _) => {},
|
||||
};
|
||||
}
|
||||
let color = Color::Rgb(0, 0, 127);
|
||||
match color {
|
||||
Color::Red => println!("Red"),
|
||||
_ => eprintln!("Not red"),
|
||||
};
|
||||
match color {
|
||||
Color::Red => {},
|
||||
Color::Green => {},
|
||||
Color::Blue => {},
|
||||
Color::Cyan => {},
|
||||
c if c.is_monochrome() => {},
|
||||
Color::Rgb(_, _, _) => {},
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue