#enums #boolean #yes #bool #no

no-std boolean-enums

Generate enums with Yes and No variants. Supports no_std and serde.

7 releases

0.3.4 Feb 17, 2020
0.3.3 Mar 16, 2019
0.3.2 Jan 20, 2019
0.3.1 Nov 1, 2018
0.1.0 Jul 14, 2018

#1167 in Rust patterns

MIT/Apache

11KB
147 lines

boolean-enums

Build Status Crates.io Documentation

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
}

License

This project is licensed under either of

at your option.

Dependencies

~165KB