1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-13 13:49:13 +02:00
comprehensive-rust/third_party/rust-by-example/match-guards.rs
2022-12-21 16:38:28 +01:00

12 lines
373 B
Rust

#[rustfmt::skip]
fn main() {
let pair = (2, -2);
println!("Tell me about {pair:?}");
match pair {
(x, y) if x == y => println!("These are twins"),
(x, y) if x + y == 0 => println!("Antimatter, kaboom!"),
(x, _) if x % 2 == 1 => println!("The first one is odd"),
_ => println!("No correlation..."),
}
}