}
impl<I: ParallelIterator + Debug, F> Debug for Inspect<I, F> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Inspect").field("base", &self.base).finish()
}
}
-/// Create a new `Inspect` iterator.
-///
-/// NB: a free fn because it is NOT part of the end-user API.
-pub fn new<I, F>(base: I, inspect_op: F) -> Inspect<I, F>
+impl<I, F> Inspect<I, F>
where
I: ParallelIterator,
{
- Inspect {
- base: base,
- inspect_op: inspect_op,
+ /// Create a new `Inspect` iterator.
+ pub(super) fn new(base: I, inspect_op: F) -> Self {
+ Inspect { base, inspect_op }
}
}
CB: ProducerCallback<Self::Item>,
{
return self.base.with_producer(Callback {
- callback: callback,
+ callback,
inspect_op: self.inspect_op,
});
P: Producer<Item = T>,
{
let producer = InspectProducer {
- base: base,
+ base,
inspect_op: &self.inspect_op,
};
self.callback.callback(producer)
impl<'f, C, F> InspectConsumer<'f, C, F> {
fn new(base: C, inspect_op: &'f F) -> Self {
- InspectConsumer {
- base: base,
- inspect_op: inspect_op,
- }
+ InspectConsumer { base, inspect_op }
}
}
}
}
+ fn consume_iter<I>(mut self, iter: I) -> Self
+ where
+ I: IntoIterator<Item = T>,
+ {
+ self.base = self
+ .base
+ .consume_iter(iter.into_iter().inspect(self.inspect_op));
+ self
+ }
+
fn complete(self) -> C::Result {
self.base.complete()
}