Answers for "rust pattern matching"

0

matching in rust

match number {
        // Match a single value
        1 => println!("One!"),
        // Match several values
        2 | 3 | 5 | 7 | 11 => println!("This is a prime"),
        // Match an inclusive range
        13..=19 => println!("A teen"),
        // Handle the rest of cases
        _ => println!("Ain't special"),
    }
Posted by: Guest on July-28-2020
0

rust pattern matching

fn main() {
    let x = 1;

    match x {
        1 => println!("one"),
        2 => println!("two"),
        3 => println!("three"),
        _ => println!("anything"),
    }
}
Posted by: Guest on July-26-2020

Code answers related to "rust pattern matching"

Browse Popular Code Answers by Language