@@ -109,6 +109,12 @@ impl<T, I: Iterator<Item = T>> UnordItems<T, I> {
109109 }
110110}
111111
112+ impl < T > UnordItems < T , std:: iter:: Empty < T > > {
113+ pub fn empty ( ) -> Self {
114+ UnordItems ( std:: iter:: empty ( ) )
115+ }
116+ }
117+
112118impl < ' a , T : Clone + ' a , I : Iterator < Item = & ' a T > > UnordItems < & ' a T , I > {
113119 #[ inline]
114120 pub fn cloned ( self ) -> UnordItems < T , impl Iterator < Item = T > > {
@@ -133,6 +139,20 @@ impl<T: Ord, I: Iterator<Item = T>> UnordItems<T, I> {
133139 items
134140 }
135141
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+
136156 pub fn into_sorted_small_vec < HCX , const LEN : usize > ( self , hcx : & HCX ) -> SmallVec < [ T ; LEN ] >
137157 where
138158 T : ToStableHashKey < HCX > ,
@@ -175,6 +195,11 @@ impl<V: Eq + Hash> UnordSet<V> {
175195 self . inner . len ( )
176196 }
177197
198+ #[ inline]
199+ pub fn is_empty ( & self ) -> bool {
200+ self . inner . is_empty ( )
201+ }
202+
178203 #[ inline]
179204 pub fn insert ( & mut self , v : V ) -> bool {
180205 self . inner . insert ( v)
@@ -253,7 +278,7 @@ impl<V: Eq + Hash> UnordSet<V> {
253278 // We can safely extend this UnordSet from a set of unordered values because that
254279 // won't expose the internal ordering anywhere.
255280 #[ 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 > ) {
257282 self . inner . extend ( items. 0 )
258283 }
259284
@@ -277,6 +302,12 @@ impl<V: Hash + Eq> FromIterator<V> for UnordSet<V> {
277302 }
278303}
279304
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+
280311impl < HCX , V : Hash + Eq + HashStable < HCX > > HashStable < HCX > for UnordSet < V > {
281312 #[ inline]
282313 fn hash_stable ( & self , hcx : & mut HCX , hasher : & mut StableHasher ) {
0 commit comments