ternary-rs 1.0.0

A Rust library for emulating the ternary operator from C/C++ (among other languages)
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 0 items with examples
  • Size
  • Source code size: 14.8 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.02 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • adamson.benjamin/ternary-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • bjadamson

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! and ternary
ifelse!(condition, true value, false value)
ternary!(condition, true value, false value)

Usage

Add this to your Cargo.toml:

[dependencies]
ternary-rs = "1.0.0"

Example

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);

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.