Programming-Idioms

History of Idiom 162 > diff from v14 to v15

Edit summary for version 15 :
New Rust implementation by user [p0lunin]

Version 14

2019-10-09, 15:56:42

Version 15

2020-04-24, 17:03:44

Idiom #162 Execute procedures depending on options

execute bat if b is a program option and fox if f is a program option.

Idiom #162 Execute procedures depending on options

execute bat if b is a program option and fox if f is a program option.

Code
if let Some(arg) = ::std::env::args().nth(1) {
    match arg.as_str() {
        "f" => fox(),
        "b" => box(),
        _ => eprintln!("invalid argument: {}", arg),
    };
} else {
    eprintln!("missing argument");
}