6
6
// option. This file may not be copied, modified, or distributed
7
7
// except according to those terms.
8
8
9
- use boxed:: BoxPredicate ;
10
-
11
9
/// Trait for generically evaluating a type against a dynamically created
12
10
/// predicate function.
13
11
///
@@ -19,35 +17,4 @@ pub trait Predicate<Item: ?Sized> {
19
17
/// Execute this `Predicate` against `variable`, returning the resulting
20
18
/// boolean.
21
19
fn eval ( & self , variable : & Item ) -> bool ;
22
-
23
- /// Returns a `BoxPredicate` wrapper around this `Predicate` type.
24
- ///
25
- /// Returns a `BoxPredicate` wrapper around this `Predicate type. The
26
- /// `BoxPredicate` type has a number of useful properties:
27
- ///
28
- /// - It stores the inner predicate as a trait object, so the type of
29
- /// `BoxPredicate` will always be the same even if steps are added or
30
- /// removed from the predicate.
31
- /// - It is a common type, allowing it to be stored in vectors or other
32
- /// collection types.
33
- /// - It implements `Debug` and `Display`.
34
- ///
35
- /// # Examples
36
- ///
37
- /// ```
38
- /// use predicates::prelude::*;
39
- ///
40
- /// let predicates = vec![
41
- /// predicate::always().boxed(),
42
- /// predicate::never().boxed(),
43
- /// ];
44
- /// assert_eq!(true, predicates[0].eval(&4));
45
- /// assert_eq!(false, predicates[1].eval(&4));
46
- /// ```
47
- fn boxed ( self ) -> BoxPredicate < Item >
48
- where
49
- Self : Sized + Send + Sync + ' static ,
50
- {
51
- BoxPredicate :: new ( self )
52
- }
53
20
}
0 commit comments