@@ -13,6 +13,7 @@ use crate::vec::Vec;
13
13
use core:: cmp:: Ordering ;
14
14
use core:: fmt;
15
15
use core:: hash:: { BuildHasher , Hash } ;
16
+ use core:: ops:: RangeBounds ;
16
17
17
18
use crate :: Bucket ;
18
19
use crate :: Entries ;
@@ -149,6 +150,43 @@ impl<K: Sync + Send, V: Send> IndexedParallelIterator for ParIterMut<'_, K, V> {
149
150
indexed_parallel_iterator_methods ! ( Bucket :: ref_mut) ;
150
151
}
151
152
153
+ /// Requires crate feature `"rayon"`.
154
+ impl < ' a , K , V , S > ParallelDrainRange < usize > for & ' a mut IndexMap < K , V , S >
155
+ where
156
+ K : Send ,
157
+ V : Send ,
158
+ {
159
+ type Item = ( K , V ) ;
160
+ type Iter = ParDrain < ' a , K , V > ;
161
+
162
+ fn par_drain < R : RangeBounds < usize > > ( self , range : R ) -> Self :: Iter {
163
+ ParDrain {
164
+ entries : self . core . par_drain ( range) ,
165
+ }
166
+ }
167
+ }
168
+
169
+ /// A parallel draining iterator over the entries of a `IndexMap`.
170
+ ///
171
+ /// This `struct` is created by the [`par_drain`] method on [`IndexMap`]
172
+ /// (provided by rayon's `ParallelDrainRange` trait). See its documentation for more.
173
+ ///
174
+ /// [`par_drain`]: ../struct.IndexMap.html#method.par_drain
175
+ /// [`IndexMap`]: ../struct.IndexMap.html
176
+ pub struct ParDrain < ' a , K : Send , V : Send > {
177
+ entries : rayon:: vec:: Drain < ' a , Bucket < K , V > > ,
178
+ }
179
+
180
+ impl < K : Send , V : Send > ParallelIterator for ParDrain < ' _ , K , V > {
181
+ type Item = ( K , V ) ;
182
+
183
+ parallel_iterator_methods ! ( Bucket :: key_value) ;
184
+ }
185
+
186
+ impl < K : Send , V : Send > IndexedParallelIterator for ParDrain < ' _ , K , V > {
187
+ indexed_parallel_iterator_methods ! ( Bucket :: key_value) ;
188
+ }
189
+
152
190
/// Parallel iterator methods and other parallel methods.
153
191
///
154
192
/// The following methods **require crate feature `"rayon"`**.
0 commit comments