macro_rules! switch {
($input:expr; $first:expr$(, $($conditions:expr),*)? => $execute:expr$(,)?) => { ... };
($input:expr; $first:expr$(, $($conditions:expr),*)? => $execute:expr, _ => $execute_last:expr$(,)?) => { ... };
($input:expr; $first:expr$(, $($conditions:expr),*)? => $execute:expr, $($rest:expr$(, $($conditions_rest:expr),*)? => $exec:expr),+$(,)?) => { ... };
($input:expr; $first:expr$(, $($conditions:expr),*)? => $execute:expr, $($rest:expr$(, $($conditions_rest:expr),*)? => $exec:expr),+, _ => $execute_last:expr$(,)?) => { ... };
}
Expand description
The macro used to emulate switch statements.
See the crate level docs for more.
ยงExample
use easy_switch::switch;
let var = 30;
let matched = switch! { var;
15 + 15 => true,
22 => {
println!("22?");
false
},
_ => false,
};
assert!(matched);