]> git.proxmox.com Git - rustc.git/blobdiff - vendor/rustc-rayon/src/iter/map.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / vendor / rustc-rayon / src / iter / map.rs
index 4db0ae32bd8ecc479e782b94ba1ddf788396c1c5..f2a35ff8c94cf2c93036a6d03cca5143db359a5c 100644 (file)
@@ -18,21 +18,18 @@ pub struct Map<I: ParallelIterator, F> {
 }
 
 impl<I: ParallelIterator + Debug, F> Debug for Map<I, F> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_struct("Map").field("base", &self.base).finish()
     }
 }
 
-/// Create a new `Map` iterator.
-///
-/// NB: a free fn because it is NOT part of the end-user API.
-pub fn new<I, F>(base: I, map_op: F) -> Map<I, F>
+impl<I, F> Map<I, F>
 where
     I: ParallelIterator,
 {
-    Map {
-        base: base,
-        map_op: map_op,
+    /// Creates a new `Map` iterator.
+    pub(super) fn new(base: I, map_op: F) -> Self {
+        Map { base, map_op }
     }
 }
 
@@ -80,7 +77,7 @@ where
         CB: ProducerCallback<Self::Item>,
     {
         return self.base.with_producer(Callback {
-            callback: callback,
+            callback,
             map_op: self.map_op,
         });
 
@@ -102,7 +99,7 @@ where
                 P: Producer<Item = T>,
             {
                 let producer = MapProducer {
-                    base: base,
+                    base,
                     map_op: &self.map_op,
                 };
                 self.callback.callback(producer)
@@ -113,7 +110,7 @@ where
 
 /// ////////////////////////////////////////////////////////////////////////
 
-struct MapProducer<'f, P, F: 'f> {
+struct MapProducer<'f, P, F> {
     base: P,
     map_op: &'f F,
 }
@@ -167,17 +164,14 @@ where
 /// ////////////////////////////////////////////////////////////////////////
 /// Consumer implementation
 
-struct MapConsumer<'f, C, F: 'f> {
+struct MapConsumer<'f, C, F> {
     base: C,
     map_op: &'f F,
 }
 
 impl<'f, C, F> MapConsumer<'f, C, F> {
     fn new(base: C, map_op: &'f F) -> Self {
-        MapConsumer {
-            base: base,
-            map_op: map_op,
-        }
+        MapConsumer { base, map_op }
     }
 }
 
@@ -227,7 +221,7 @@ where
     }
 }
 
-struct MapFolder<'f, C, F: 'f> {
+struct MapFolder<'f, C, F> {
     base: C,
     map_op: &'f F,
 }
@@ -247,6 +241,14 @@ where
         }
     }
 
+    fn consume_iter<I>(mut self, iter: I) -> Self
+    where
+        I: IntoIterator<Item = T>,
+    {
+        self.base = self.base.consume_iter(iter.into_iter().map(self.map_op));
+        self
+    }
+
     fn complete(self) -> C::Result {
         self.base.complete()
     }