#ternary #operator

conditional

Provides a conditional! macro which lets you use the syntax of the conditional operator (also known as the ternary operator) in Rust

2 releases

0.1.1 Sep 22, 2019
0.1.0 Sep 22, 2019

#2254 in Rust patterns

Download history 9/week @ 2023-06-16 8/week @ 2023-06-23 6/week @ 2023-06-30 3/week @ 2023-07-07 3/week @ 2023-07-14 5/week @ 2023-07-21 4/week @ 2023-07-28 4/week @ 2023-08-04 5/week @ 2023-08-11 59/week @ 2023-08-18 55/week @ 2023-08-25 52/week @ 2023-09-01 127/week @ 2023-09-08 121/week @ 2023-09-15 82/week @ 2023-09-22

391 downloads per month

MIT/Apache

4KB

conditional

Crates.io Crates.io Crates.io Docs.io

Lets you use the syntax of the conditional operator in Rust. Also known as the ternary operator.

Examples

let x = conditional!(69 > 42 ? "hello" : "world");
assert_eq!(x, "hello");

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1–1.2MB
~31K SLoC