@@ -109,6 +109,12 @@ impl<T, I: Iterator<Item = T>> UnordItems<T, I> {
109
109
}
110
110
}
111
111
112
+ impl < T > UnordItems < T , std:: iter:: Empty < T > > {
113
+ pub fn empty ( ) -> Self {
114
+ UnordItems ( std:: iter:: empty ( ) )
115
+ }
116
+ }
117
+
112
118
impl < ' a , T : Clone + ' a , I : Iterator < Item = & ' a T > > UnordItems < & ' a T , I > {
113
119
#[ inline]
114
120
pub fn cloned ( self ) -> UnordItems < T , impl Iterator < Item = T > > {
@@ -133,6 +139,20 @@ impl<T: Ord, I: Iterator<Item = T>> UnordItems<T, I> {
133
139
items
134
140
}
135
141
142
+ #[ inline]
143
+ pub fn into_sorted_stable_ord ( self , use_stable_sort : bool ) -> Vec < T >
144
+ where
145
+ T : Ord + StableOrd ,
146
+ {
147
+ let mut items: Vec < T > = self . 0 . collect ( ) ;
148
+ if use_stable_sort {
149
+ items. sort ( ) ;
150
+ } else {
151
+ items. sort_unstable ( )
152
+ }
153
+ items
154
+ }
155
+
136
156
pub fn into_sorted_small_vec < HCX , const LEN : usize > ( self , hcx : & HCX ) -> SmallVec < [ T ; LEN ] >
137
157
where
138
158
T : ToStableHashKey < HCX > ,
@@ -175,6 +195,11 @@ impl<V: Eq + Hash> UnordSet<V> {
175
195
self . inner . len ( )
176
196
}
177
197
198
+ #[ inline]
199
+ pub fn is_empty ( & self ) -> bool {
200
+ self . inner . is_empty ( )
201
+ }
202
+
178
203
#[ inline]
179
204
pub fn insert ( & mut self , v : V ) -> bool {
180
205
self . inner . insert ( v)
@@ -253,7 +278,7 @@ impl<V: Eq + Hash> UnordSet<V> {
253
278
// We can safely extend this UnordSet from a set of unordered values because that
254
279
// won't expose the internal ordering anywhere.
255
280
#[ inline]
256
- pub fn extend < I : Iterator < Item = V > > ( & mut self , items : UnordItems < V , I > ) {
281
+ pub fn extend_unord < I : Iterator < Item = V > > ( & mut self , items : UnordItems < V , I > ) {
257
282
self . inner . extend ( items. 0 )
258
283
}
259
284
@@ -277,6 +302,12 @@ impl<V: Hash + Eq> FromIterator<V> for UnordSet<V> {
277
302
}
278
303
}
279
304
305
+ impl < V : Hash + Eq > From < FxHashSet < V > > for UnordSet < V > {
306
+ fn from ( value : FxHashSet < V > ) -> Self {
307
+ UnordSet { inner : value }
308
+ }
309
+ }
310
+
280
311
impl < HCX , V : Hash + Eq + HashStable < HCX > > HashStable < HCX > for UnordSet < V > {
281
312
#[ inline]
282
313
fn hash_stable ( & self , hcx : & mut HCX , hasher : & mut StableHasher ) {
0 commit comments