Answers for "rust match enum"

0

rust match enum

//suppose this was passed by the user and you stored in a variable
    let choice = Choice::One; 
    match choice {
        Choice::One => println!("Option 1"),
        Choice::Two => println!("Option 2"),
        Choice::Three => println!("Option 3"),
    }
Posted by: Guest on November-09-2021

Browse Popular Code Answers by Language