@@ -20,26 +20,26 @@ use Predicate;
20
20
/// Note that this implementation places the fewest restrictions on the
21
21
/// underlying `Item` type at the expense of having the least performant
22
22
/// implementation (linear search). If the type to be searched is `Hash + Eq`,
23
- /// it is much more efficient to use `HashableContainsPredicate ` and
24
- /// `contains_hashable `. The implementation-specific predicates will be
23
+ /// it is much more efficient to use `HashableInPredicate ` and
24
+ /// `in_hash `. The implementation-specific predicates will be
25
25
/// deprecated when Rust supports trait specialization.
26
26
#[ derive( Debug ) ]
27
- pub struct ContainsPredicate < T >
27
+ pub struct InPredicate < T >
28
28
where
29
29
T : PartialEq ,
30
30
{
31
31
inner : Vec < T > ,
32
32
}
33
33
34
- impl < T > ContainsPredicate < T >
34
+ impl < T > InPredicate < T >
35
35
where
36
36
T : Ord ,
37
37
{
38
38
/// Creates a new predicate that will return `true` when the given `variable` is
39
39
/// contained with the set of items provided.
40
40
///
41
41
/// Note that this implementation requires `Item` to be `Ord`. The
42
- /// `ContainsPredicate ` uses a less efficient search algorithm but only
42
+ /// `InPredicate ` uses a less efficient search algorithm but only
43
43
/// requires `Item` implement `PartialEq`. The implementation-specific
44
44
/// predicates will be deprecated when Rust supports trait specialization.
45
45
///
@@ -48,21 +48,21 @@ where
48
48
/// ```
49
49
/// use predicates::prelude::*;
50
50
///
51
- /// let predicate_fn = predicate::contains (vec![1, 3, 5]).ord ();
51
+ /// let predicate_fn = predicate::in_iter (vec![1, 3, 5]).sort ();
52
52
/// assert_eq!(true, predicate_fn.eval(&1));
53
53
/// assert_eq!(false, predicate_fn.eval(&2));
54
54
/// assert_eq!(true, predicate_fn.eval(&3));
55
55
/// assert_eq!(false, predicate_fn.eval(&4));
56
56
/// assert_eq!(true, predicate_fn.eval(&5));
57
57
/// ```
58
- pub fn ord ( self ) -> OrdContainsPredicate < T > {
58
+ pub fn sort ( self ) -> OrdInPredicate < T > {
59
59
let mut items = self . inner ;
60
60
items. sort ( ) ;
61
- OrdContainsPredicate { inner : items }
61
+ OrdInPredicate { inner : items }
62
62
}
63
63
}
64
64
65
- impl < T > Predicate < T > for ContainsPredicate < T >
65
+ impl < T > Predicate < T > for InPredicate < T >
66
66
where
67
67
T : PartialEq ,
68
68
{
@@ -77,28 +77,28 @@ where
77
77
/// Note that this implementation places the fewest restrictions on the
78
78
/// underlying `Item` type at the expense of having the least performant
79
79
/// implementation (linear search). If the type to be searched is `Hash + Eq`,
80
- /// it is much more efficient to use `HashableContainsPredicate ` and
81
- /// `contains_hashable `. The implementation-specific predicates will be
80
+ /// it is much more efficient to use `HashableInPredicate ` and
81
+ /// `in_hash `. The implementation-specific predicates will be
82
82
/// deprecated when Rust supports trait specialization.
83
83
///
84
84
/// # Examples
85
85
///
86
86
/// ```
87
87
/// use predicates::prelude::*;
88
88
///
89
- /// let predicate_fn = predicate::contains (vec![1, 3, 5]);
89
+ /// let predicate_fn = predicate::in_iter (vec![1, 3, 5]);
90
90
/// assert_eq!(true, predicate_fn.eval(&1));
91
91
/// assert_eq!(false, predicate_fn.eval(&2));
92
92
/// assert_eq!(true, predicate_fn.eval(&3));
93
93
/// assert_eq!(false, predicate_fn.eval(&4));
94
94
/// assert_eq!(true, predicate_fn.eval(&5));
95
95
/// ```
96
- pub fn contains < I , T > ( iter : I ) -> ContainsPredicate < T >
96
+ pub fn in_iter < I , T > ( iter : I ) -> InPredicate < T >
97
97
where
98
98
T : PartialEq ,
99
99
I : IntoIterator < Item = T > ,
100
100
{
101
- ContainsPredicate {
101
+ InPredicate {
102
102
inner : Vec :: from_iter ( iter) ,
103
103
}
104
104
}
@@ -107,20 +107,20 @@ where
107
107
/// set, otherwise returns `false`.
108
108
///
109
109
/// Note that this implementation requires `Item` to be `Ord`. The
110
- /// `ContainsPredicate ` uses a less efficient search algorithm but only
110
+ /// `InPredicate ` uses a less efficient search algorithm but only
111
111
/// requires `Item` implement `PartialEq`. The implementation-specific
112
112
/// predicates will be deprecated when Rust supports trait specialization.
113
113
///
114
- /// This is created by the `predicate::contains (...).ord ` function.
114
+ /// This is created by the `predicate::in_iter (...).sort ` function.
115
115
#[ derive( Debug ) ]
116
- pub struct OrdContainsPredicate < T >
116
+ pub struct OrdInPredicate < T >
117
117
where
118
118
T : Ord ,
119
119
{
120
120
inner : Vec < T > ,
121
121
}
122
122
123
- impl < T > Predicate < T > for OrdContainsPredicate < T >
123
+ impl < T > Predicate < T > for OrdInPredicate < T >
124
124
where
125
125
T : Ord ,
126
126
{
@@ -133,20 +133,20 @@ where
133
133
/// `HashSet`, otherwise returns `false`.
134
134
///
135
135
/// Note that this implementation requires `Item` to be `Hash + Eq`. The
136
- /// `ContainsPredicate ` uses a less efficient search algorithm but only
136
+ /// `InPredicate ` uses a less efficient search algorithm but only
137
137
/// requires `Item` implement `PartialEq`. The implementation-specific
138
138
/// predicates will be deprecated when Rust supports trait specialization.
139
139
///
140
- /// This is created by the `predicate::contains_hashable ` function.
140
+ /// This is created by the `predicate::in_hash ` function.
141
141
#[ derive( Debug ) ]
142
- pub struct HashableContainsPredicate < T >
142
+ pub struct HashableInPredicate < T >
143
143
where
144
144
T : Hash + Eq ,
145
145
{
146
146
inner : HashSet < T > ,
147
147
}
148
148
149
- impl < T > Predicate < T > for HashableContainsPredicate < T >
149
+ impl < T > Predicate < T > for HashableInPredicate < T >
150
150
where
151
151
T : Hash + Eq ,
152
152
{
@@ -159,7 +159,7 @@ where
159
159
/// contained with the set of items provided.
160
160
///
161
161
/// Note that this implementation requires `Item` to be `Hash + Eq`. The
162
- /// `ContainsPredicate ` uses a less efficient search algorithm but only
162
+ /// `InPredicate ` uses a less efficient search algorithm but only
163
163
/// requires `Item` implement `PartialEq`. The implementation-specific
164
164
/// predicates will be deprecated when Rust supports trait specialization.
165
165
///
@@ -168,19 +168,19 @@ where
168
168
/// ```
169
169
/// use predicates::prelude::*;
170
170
///
171
- /// let predicate_fn = predicate::contains_hashable (vec![1, 3, 5]);
171
+ /// let predicate_fn = predicate::in_hash (vec![1, 3, 5]);
172
172
/// assert_eq!(true, predicate_fn.eval(&1));
173
173
/// assert_eq!(false, predicate_fn.eval(&2));
174
174
/// assert_eq!(true, predicate_fn.eval(&3));
175
175
/// assert_eq!(false, predicate_fn.eval(&4));
176
176
/// assert_eq!(true, predicate_fn.eval(&5));
177
177
/// ```
178
- pub fn contains_hashable < I , T > ( iter : I ) -> HashableContainsPredicate < T >
178
+ pub fn in_hash < I , T > ( iter : I ) -> HashableInPredicate < T >
179
179
where
180
180
T : Hash + Eq ,
181
181
I : IntoIterator < Item = T > ,
182
182
{
183
- HashableContainsPredicate {
183
+ HashableInPredicate {
184
184
inner : HashSet :: from_iter ( iter) ,
185
185
}
186
186
}
0 commit comments