9 releases
Uses new Rust 2024
| new 0.4.1 | Dec 2, 2025 |
|---|---|
| 0.4.0 | Nov 26, 2025 |
| 0.3.4 | Feb 17, 2020 |
| 0.3.3 | Mar 16, 2019 |
| 0.3.0 | Jul 20, 2018 |
#647 in Rust patterns
11KB
149 lines
boolean-enums
Convenient macro to generate enums with Yes and No variants.
Supports no_std.
Useful in cases of multiple bool arguments:
use boolean_enums::gen_boolean_enum;
gen_boolean_enum!(First);
gen_boolean_enum!(Second);
gen_boolean_enum!(Third);
fn do_smth(flag1: First, flag2: Second, flag3: Third) {
// …
}
fn main() {
let first = First::Yes;
let second = Second::No;
let third = Third::Yes;
do_smth(first, second, third); // compiles
do_smth(first, third, second); // fails
}
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Dependencies
~170KB