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
#[derive(Debug, Clone)]
pub struct AllAny {
all: bool,
any: bool,
}
impl AllAny {
pub fn new() -> Self {
Self {
all: true,
any: false,
}
}
pub fn clear(&mut self) {
self.all = true;
self.any = false;
}
pub fn add(&mut self, new_bool: bool) {
self.all = self.all && new_bool;
self.any = self.any || new_bool;
}
pub fn all(&self) -> bool {
self.all
}
pub fn any(&self) -> bool {
self.any
}
pub fn merge(&mut self, other: Self) {
self.all = self.all && other.all;
self.any = self.any || other.any;
}
}