@@ -38,17 +38,17 @@ impl<T, I: Iterator<Item = T>> UnordItems<T, I> {
38
38
}
39
39
40
40
#[ inline]
41
- pub fn all < U , F : Fn ( T ) -> bool > ( mut self , f : F ) -> bool {
41
+ pub fn all < F : Fn ( T ) -> bool > ( mut self , f : F ) -> bool {
42
42
self . 0 . all ( f)
43
43
}
44
44
45
45
#[ inline]
46
- pub fn any < U , F : Fn ( T ) -> bool > ( mut self , f : F ) -> bool {
46
+ pub fn any < F : Fn ( T ) -> bool > ( mut self , f : F ) -> bool {
47
47
self . 0 . any ( f)
48
48
}
49
49
50
50
#[ inline]
51
- pub fn filter < U , F : Fn ( & T ) -> bool > ( self , f : F ) -> UnordItems < T , impl Iterator < Item = T > > {
51
+ pub fn filter < F : Fn ( & T ) -> bool > ( self , f : F ) -> UnordItems < T , impl Iterator < Item = T > > {
52
52
UnordItems ( self . 0 . filter ( f) )
53
53
}
54
54
@@ -96,6 +96,15 @@ impl<T, I: Iterator<Item = T>> UnordItems<T, I> {
96
96
pub fn count ( self ) -> usize {
97
97
self . 0 . count ( )
98
98
}
99
+
100
+ #[ inline]
101
+ pub fn flat_map < U , F , O > ( self , f : F ) -> UnordItems < O , impl Iterator < Item = O > >
102
+ where
103
+ U : IntoIterator < Item = O > ,
104
+ F : Fn ( T ) -> U ,
105
+ {
106
+ UnordItems ( self . 0 . flat_map ( f) )
107
+ }
99
108
}
100
109
101
110
impl < ' a , T : Clone + ' a , I : Iterator < Item = & ' a T > > UnordItems < & ' a T , I > {
@@ -193,6 +202,11 @@ impl<V: Eq + Hash> UnordSet<V> {
193
202
pub fn extend < I : Iterator < Item = V > > ( & mut self , items : UnordItems < V , I > ) {
194
203
self . inner . extend ( items. 0 )
195
204
}
205
+
206
+ #[ inline]
207
+ pub fn clear ( & mut self ) {
208
+ self . inner . clear ( ) ;
209
+ }
196
210
}
197
211
198
212
impl < V : Hash + Eq > Extend < V > for UnordSet < V > {
@@ -201,6 +215,12 @@ impl<V: Hash + Eq> Extend<V> for UnordSet<V> {
201
215
}
202
216
}
203
217
218
+ impl < V : Hash + Eq > FromIterator < V > for UnordSet < V > {
219
+ fn from_iter < T : IntoIterator < Item = V > > ( iter : T ) -> Self {
220
+ UnordSet { inner : FxHashSet :: from_iter ( iter) }
221
+ }
222
+ }
223
+
204
224
impl < HCX , V : Hash + Eq + HashStable < HCX > > HashStable < HCX > for UnordSet < V > {
205
225
#[ inline]
206
226
fn hash_stable ( & self , hcx : & mut HCX , hasher : & mut StableHasher ) {
0 commit comments