meta_language/
semantics.rs1#[derive(Clone, Copy, Debug, PartialEq, Eq)]
3pub enum TruthValue {
4 True,
5 False,
6 Unknown,
7 Both,
8}
9
10impl TruthValue {
11 #[must_use]
13 pub const fn and(self, other: Self) -> Self {
14 match (self, other) {
15 (Self::False, _) | (_, Self::False) => Self::False,
16 (Self::True, value) | (value, Self::True) => value,
17 (Self::Both, _) | (_, Self::Both) => Self::Both,
18 (Self::Unknown, Self::Unknown) => Self::Unknown,
19 }
20 }
21
22 #[must_use]
24 pub const fn or(self, other: Self) -> Self {
25 match (self, other) {
26 (Self::True, _) | (_, Self::True) => Self::True,
27 (Self::False, value) | (value, Self::False) => value,
28 (Self::Both, _) | (_, Self::Both) => Self::Both,
29 (Self::Unknown, Self::Unknown) => Self::Unknown,
30 }
31 }
32
33 #[must_use]
35 pub const fn negate(self) -> Self {
36 match self {
37 Self::True => Self::False,
38 Self::False => Self::True,
39 Self::Unknown => Self::Unknown,
40 Self::Both => Self::Both,
41 }
42 }
43}