1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use crate::filter::OpVal;

#[derive(Debug)]
pub struct OpValsBool(pub Vec<OpValBool>);

#[derive(Debug, Clone)]
pub enum OpValBool {
	Eq(bool),
	Not(bool),
	Empty(bool),
}

// region:    --- Primitive to BoolOpVal
impl From<bool> for OpValBool {
	fn from(val: bool) -> Self {
		OpValBool::Eq(val)
	}
}

impl From<&bool> for OpValBool {
	fn from(val: &bool) -> Self {
		OpValBool::Eq(*val)
	}
}
// endregion: --- Primitive to BoolOpVal

// region:    --- BoolOpVal to OpVal
impl From<OpValBool> for OpVal {
	fn from(val: OpValBool) -> Self {
		OpVal::Bool(val)
	}
}
// endregion: --- BoolOpVal to OpVal

// region:    --- Primitive to OpVal::Bool(BoolOpVal::Eq)
impl From<bool> for OpVal {
	fn from(val: bool) -> Self {
		OpValBool::Eq(val).into()
	}
}

impl From<&bool> for OpVal {
	fn from(val: &bool) -> Self {
		OpValBool::Eq(*val).into()
	}
}
// endregion: --- Primitive to OpVal::Bool(BoolOpVal::Eq)

// region:    --- is_match
impl OpValBool {
	/// Matches a target value (`t_val`) with the BoolOpVal pattern value (`p_val`)
	pub fn is_match(&self, t_val: bool) -> bool {
		use OpValBool::*;

		match self {
			Eq(p_val) => &t_val == p_val,
			Not(p_val) => &t_val != p_val,
			Empty(_) => false, // always false per this function signature.
		}
	}
}
// endregion: --- is_match