| fn main() { | |
| let pair = (2i, -2); | |
| // TODO ^ Try different values for `pair` | |
| println!("Tell me about {}", pair); | |
| // Match can be used to destructure a tuple | |
| match pair { | |
| // Destructure the tuple | |
| (x, y) if x == y => println!("These are twins"), | |
| // The ^ `if condition` part is a guard | |
| (x, y) if x + y == 0 => println!("Antimatter, kaboom!"), | |
| // `_` means don't bind the value to a variable | |
| (x, _) if x % 2 == 1 => println!("The first one is odd"), | |
| _ => println!("No correlation..."), | |
| } | |
| } |