ternary-rs
A Rust library for emulating the ternary operator from C/C++ (among other languages)
Exposes two macros that do the same thing:
- Choose between two macros
ifelse!
andternary
ifelse!
ternary!
Usage
Add this to your Cargo.toml
:
[]
= "1.0.0"
Example
let cond = true;
let result = if_else!;
assert_eq!;
assert_ne!;
// If you find if_else!() unclear, you can use the ternary!() macro and be explicit instead!
let result = ternary!;
assert_eq!;
assert_ne!;
License
ternary-rs is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.