[−][src]Crate condition
This library provides condition::Condition
a trait for
easier expression (and consumption) of features, toggles, checkboxes,
settings, options, or any other bivalent pair.
NOTE: This crate will eventually support no-std, but does not at this time
Conditions typically come in pairs. (e.g., {Allow, Deny}
, {Yes, No}
,
{With, Without}
. This library provides several types by default. To
import them, use the prelude
module. If you only want to use
the trait, simply import it.
Use impl Condition
anywhere you might take a boolean value. Then, use
any type that implements this condition.
Within the function, branch off of the condition provided
use condition::prelude::*; #[derive(Condition)] enum Answer { No, Yes } pub fn verbose(v: impl Condition) { assert!(v.is(false)); } /* ... */ use Answer::No; verbose(No);
Modules
prelude |
Traits
Condition |