match compares a value against patterns and runs the first arm that fits. _ is the catch-all.

Program

Play the program to map a numeric code to a label.

match_value.rs
fn main() {
    let code = 2;
    let label = match code {
        1 => "one",
        2 => "two",
        _ => "many",
    };
    println!("{label}");
}
match `match` picks one arm based on the value.
arm Each `pattern => value` is one arm.
wildcard `_` matches anything not already handled.