chj_unix_util/
eval_with_default.rs

1/// Evaluate a set of explicit yes and explicit no boolean values to a
2/// single boolean, given a default yes or no.
3pub trait EvalWithDefault {
4    fn explicit_yes_and_no(&self) -> (bool, bool);
5
6    fn eval_with_default(&self, default: bool) -> bool {
7        match self.explicit_yes_and_no() {
8            (true, false) => true,
9            (false, true) => false,
10            (false, false) | (true, true) => default,
11        }
12    }
13}