A match guard adds an `if` condition to a pattern; the branch matches only when both the pattern and condition match. The condition can use the matched value or another value. section 3.1.1
fn match_with_guard(value: i32, choose_first: bool) {
match value {
v if v == 1 && choose_first => {
println!("First match: This value is equal to 1")
}
v if v == 1 && !choose_first => {
println!("Second match: This value is equal to 1")
}
v if choose_first => {
println!("First match: This value is equal to {v}")
}
v if !choose_first => {
println!("Second match: This value is equal to {v}")
}
_ => println!("Fell through to the default case"),
}
}
The value and `choose_first` conditions demonstrate guards selecting among branches, with a default case if none matches. section 3.1.1



