ternop/lib.rs
1//! A dead simple ternary operator macro which allows you to write
2//! quick one-line returnes for a variety of types.
3//!
4//! # Examples
5//!
6//! To use the ternary operator just invoke the `ternary` macro
7//!
8//! ```rust
9//! fn is_ipv4(val: &str) -> i32 {
10//! ternary!(val == "ipv4", 4, 16)
11//! }
12//! ```
13
14#[macro_export]
15macro_rules! ternary {
16 ($condition: expr, $_true: expr, $_false: expr) => {
17 if $condition { $_true } else { $_false }
18 };
19}