Crates.io | boolean-enums |
lib.rs | boolean-enums |
version | 0.3.4 |
source | src |
created_at | 2018-07-14 17:03:09.291556 |
updated_at | 2020-02-17 15:41:29.745154 |
description | Generate enums with Yes and No variants. Supports no_std and serde. |
homepage | |
repository | https://github.com/dmnsafonov/boolean-enums |
max_upload_size | |
id | 74230 |
size | 23,120 |
Convenient macro to generate enums with Yes and No variants.
Supports no_std
.
Useful in cases of multiple bool arguments:
#[macro_use] extern crate boolean_enums;
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
}
This project is licensed under either of
at your option.