How to Use the match Expression in Rust

The match expression in Rust compares a value against patterns to execute specific code blocks for each case.

The match expression compares a value against a series of patterns and executes the code block associated with the first pattern that matches.

fn main() {
    let number = 13;

    match number {
        1 => println!("One"),
        2 | 3 | 5 | 7 | 11 => println!("This is a prime"),
        _ => println!("Something else"),
    }
}