]> git.proxmox.com Git - rustc.git/blobdiff - vendor/rustc-rayon/src/iter/flat_map.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / vendor / rustc-rayon / src / iter / flat_map.rs
index 5043dd17f586ed4f8716278017520f8c8ad86f1d..f264e1e144fd932314f9a1c5b199914132f47b4b 100644 (file)
@@ -3,7 +3,7 @@ use super::*;
 
 use std::fmt::{self, Debug};
 
-/// `FlatMap` maps each element to an iterator, then flattens these iterators together.
+/// `FlatMap` maps each element to a parallel iterator, then flattens these iterators together.
 /// This struct is created by the [`flat_map()`] method on [`ParallelIterator`]
 ///
 /// [`flat_map()`]: trait.ParallelIterator.html#method.flat_map
@@ -22,7 +22,7 @@ impl<I: ParallelIterator + Debug, F> Debug for FlatMap<I, F> {
 }
 
 impl<I: ParallelIterator, F> FlatMap<I, F> {
-    /// Create a new `FlatMap` iterator.
+    /// Creates a new `FlatMap` iterator.
     pub(super) fn new(base: I, map_op: F) -> Self {
         FlatMap { base, map_op }
     }
@@ -40,10 +40,7 @@ where
     where
         C: UnindexedConsumer<Self::Item>,
     {
-        let consumer = FlatMapConsumer {
-            base: consumer,
-            map_op: &self.map_op,
-        };
+        let consumer = FlatMapConsumer::new(consumer, &self.map_op);
         self.base.drive_unindexed(consumer)
     }
 }
@@ -126,10 +123,9 @@ where
     fn consume(self, item: T) -> Self {
         let map_op = self.map_op;
         let par_iter = map_op(item).into_par_iter();
-        let result = par_iter.drive_unindexed(self.base.split_off_left());
+        let consumer = self.base.split_off_left();
+        let result = par_iter.drive_unindexed(consumer);
 
-        // We expect that `previous` is `None`, because we drive
-        // the cost up so high, but just in case.
         let previous = match self.previous {
             None => Some(result),
             Some(previous) => {