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
use std::fmt;
use Predicate;
pub struct BoxPredicate<Item: ?Sized>(Box<Predicate<Item> + Send + Sync>);
impl<Item> BoxPredicate<Item>
where
Item: ?Sized,
{
pub fn new<P: Predicate<Item>>(inner: P) -> BoxPredicate<Item>
where
P: Send + Sync + 'static,
{
BoxPredicate(Box::new(inner))
}
}
impl<Item> fmt::Debug for BoxPredicate<Item>
where
Item: ?Sized,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("BoxPredicate").finish()
}
}
impl<Item> fmt::Display for BoxPredicate<Item>
where
Item: ?Sized,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "BoxPredicate")
}
}
impl<Item> Predicate<Item> for BoxPredicate<Item>
where
Item: ?Sized,
{
fn eval(&self, variable: &Item) -> bool {
self.0.eval(variable)
}
}