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
pub fn and(l: Option<bool>, r: Option<bool>) -> Option<bool> {
match (l, r) {
(Some(true), Some(true)) => Some(true),
(Some(false), _) => Some(false),
(_, Some(false)) => Some(false),
_ => None,
}
}
pub fn or(l: Option<bool>, r: Option<bool>) -> Option<bool> {
match (l, r) {
(Some(false), Some(false)) => Some(false),
(Some(true), _) => Some(true),
(_, Some(true)) => Some(true),
_ => None,
}
}
pub fn imp(l: Option<bool>, r: Option<bool>) -> Option<bool> {
match (l, r) {
(Some(true), Some(false)) => Some(false),
(Some(false), _) => Some(true),
(_, Some(true)) => Some(true),
_ => None,
}
}
pub fn iff(l: Option<bool>, r: Option<bool>) -> Option<bool> {
match (l, r) {
(Some(l), Some(r)) => Some(l == r),
_ => None,
}
}
pub fn xor(l: Option<bool>, r: Option<bool>) -> Option<bool> {
match (l, r) {
(Some(l), Some(r)) => Some(l ^ r),
_ => None,
}
}
pub fn and_not(l: Option<bool>, r: Option<bool>) -> Option<bool> {
match (l, r) {
(Some(false), _) => Some(false),
(_, Some(true)) => Some(false),
(Some(true), Some(false)) => Some(true),
_ => None,
}
}