How to use match guards

Add an `if` condition after a pattern in a `match` arm to execute code only when both the pattern matches and the condition is true.

Use a match guard by adding an if condition after a pattern in a match arm to filter matches based on a boolean expression.

match x {
    Some(n) if n > 5 => println!("Greater than 5"),
    Some(n) => println!("5 or less"),
    None => println!("No value"),
}

The if n > 5 part is the match guard; the arm only executes if the pattern Some(n) matches AND the condition is true.