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
#[macro_export]
macro_rules! filter_extension {
($($t:ty, $uobj: ty, $filter: ty)*) => {
$(
impl $t {
#[inline]
/// This method is used to add an 'and' condition filter with the parent filter.
pub fn and(mut self, filter: Box<$filter>) -> Box<Self> {
self.and_filter = Some(filter);
Box::from(self)
}
/// This method is used to add an 'or' condition filter with the parent filter.
pub fn or(mut self, filter: Box<$filter>) -> Box<Self> {
self.or_filter = Some(filter);
Box::from(self)
}
pub fn invert(mut self) -> Box<Self> {
self.inverted = true;
Box::from(self)
}
pub fn check_integral_filter(&self, m: &$uobj, mut parent_result: bool) -> bool {
if self.inverted {
parent_result = !parent_result;
}
if self.and_filter.is_none() && self.or_filter.is_none() {
return parent_result
}
(
(
parent_result
&&
self.and_filter.is_some()
&&
self.and_filter.as_ref().unwrap().check_filter(m)
) || (
parent_result
)
) || (
self.or_filter.is_some()
&&
self.or_filter.as_ref().unwrap().check_filter(m)
)
}
}
)*
}
}