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