Rust doesn't support return (condition) ? if_true : if_false;
. This crate exports a macro that implements this feature.
rust
fn is_ipv4(val: &str) -> i32 {
ternary!(val == "ipv4", 4, 16)
}
If you just want to copy the small macro, here you go 😅
```
macrorules! ternary { ($condition: expr, $true: expr, $false: expr) => { if $condition { $true } else { $_false } }; } ```