criterium/boolean/
direct_match.rs1use crate::boolean::BooleanCriterium;
8use crate::direct_match::DirectMatchResult;
9use crate::DirectMatch;
10
11impl DirectMatch<bool> for BooleanCriterium {
12 type Output = bool;
13
14 fn criterium_match(&self, data: &bool) -> bool {
15 match self {
16 Self::Equals(other) => data == other,
17 Self::IsNone => false,
18 }
19 }
20}
21
22impl<V> DirectMatch<Option<V>> for BooleanCriterium
23where
24 BooleanCriterium: DirectMatch<V>,
25{
26 type Output = <Self as DirectMatch<V>>::Output;
27
28 fn criterium_match(&self, data: &Option<V>) -> Self::Output {
29 match &data {
30 Some(data) => self.criterium_match(data),
31 None => Self::Output::new(matches!(self, Self::IsNone)),
32 }
33 }
34}