macro_rules! tern_c {
(($cond:expr) ? { $if_expr:expr } : { $else_expr:expr }) => { ... };
}
Expand description
You miss C-like ternary conditions? Why not having them in Rust then?
let y = 4;
let x = tern_c! { (y & 1 == 0) ? { "even" } : { "odd" } };
println!("{} is {}", y, x);