Guards
A match guard can be added to filter the arm.
1. fn main() {
2. let pair = (2, -2);
3. // TODO ^ Try different values for `pair`
5. println!("Tell me about {:?}", pair);
6. match pair {
7. (x, y) if x == y => println!("These are twins"),
8. // The ^ `if condition` part is a guard
9. (x, y) if x + y == 0 => println!("Antimatter, kaboom!"),
10. (x, _) if x % 2 == 1 => println!("The first one is odd"),
11. _ => println!("No correlation..."),
12. }
13. }
