| Crates.io | ternary-rs |
| lib.rs | ternary-rs |
| version | 1.0.0 |
| created_at | 2021-01-15 12:53:32.947453+00 |
| updated_at | 2021-01-15 12:53:32.947453+00 |
| description | A Rust library for emulating the ternary operator from C/C++ (among other languages) |
| homepage | |
| repository | https://gitlab.com/adamson.benjamin/ternary-rs |
| max_upload_size | |
| id | 342372 |
| size | 15,178 |
A Rust library for emulating the ternary operator from C/C++ (among other languages)
Exposes two macros that do the same thing:
ifelse! and ternaryifelse!(condition, true value, false value)
ternary!(condition, true value, false value)
Add this to your Cargo.toml:
[dependencies]
ternary-rs = "1.0.0"
let cond = true;
let result = if_else!(cond, 1, 0);
assert_eq!(1, result);
assert_ne!(0, result);
// If you find if_else!() unclear, you can use the ternary!() macro and be explicit instead!
let result = ternary!(cond, 1, 0);
assert_eq!(1, result);
assert_ne!(0, result);
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.