}
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 }
}
}
CB: ProducerCallback<Self::Item>,
{
return self.base.with_producer(Callback {
- callback: callback,
+ callback,
map_op: self.map_op,
});
P: Producer<Item = T>,
{
let producer = MapProducer {
- base: base,
+ base,
map_op: &self.map_op,
};
self.callback.callback(producer)
/// ////////////////////////////////////////////////////////////////////////
-struct MapProducer<'f, P, F: 'f> {
+struct MapProducer<'f, P, F> {
base: P,
map_op: &'f F,
}
/// ////////////////////////////////////////////////////////////////////////
/// 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 }
}
}
}
}
-struct MapFolder<'f, C, F: 'f> {
+struct MapFolder<'f, C, F> {
base: C,
map_op: &'f F,
}
}
}
+ 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()
}