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
#[cfg(test)]
mod tests {
use Trit;
#[test]
fn can_be_both() {
assert!(Trit::Both.is_true());
assert!(Trit::Both.is_false());
}
#[test]
fn can_be_only() {
assert!(Trit::True.only_true());
assert!(Trit::False.only_false());
}
}
#[derive(PartialEq)]
pub enum Trit {
True,
False,
Both
}
impl Trit {
pub fn is_true(self) -> bool {
self == Trit::True || self == Trit::Both
}
pub fn is_false(self) -> bool {
self == Trit::False || self == Trit::Both
}
pub fn only_true(self) -> bool {
self == Trit::True
}
pub fn only_false(self) -> bool {
self == Trit::False
}
pub fn is_both(self) -> bool {
self == Trit::Both
}
}