usesuper::plumbing::*; usesuper::*; use std::sync::atomic::{AtomicBool, Ordering};
/// `WhileSome` is an iterator that yields the `Some` elements of an iterator, /// halting as soon as any `None` is produced. /// /// This struct is created by the [`while_some()`] method on [`ParallelIterator`] /// /// [`while_some()`]: trait.ParallelIterator.html#method.while_some /// [`ParallelIterator`]: trait.ParallelIterator.html #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[derive(Debug, Clone)] pubstruct WhileSome<I: ParallelIterator> {
base: I,
}
impl<I> WhileSome<I> where
I: ParallelIterator,
{ /// Creates a new `WhileSome` iterator. pub(super) fn new(base: I) -> Self {
WhileSome { base }
}
}
impl<I, T> ParallelIterator for WhileSome<I> where
I: ParallelIterator<Item = Option<T>>,
T: Send,
{ type Item = T;
fn drive_unindexed<C>(self, consumer: C) -> C::Result where
C: UnindexedConsumer<Self::Item>,
{ let full = AtomicBool::new(false); let consumer1 = WhileSomeConsumer {
base: consumer,
full: &full,
}; self.base.drive_unindexed(consumer1)
}
}
impl<'f, T, C> Consumer<Option<T>> for WhileSomeConsumer<'f, C> where
C: Consumer<T>,
T: Send,
{ type Folder = WhileSomeFolder<'f, C::Folder>; type Reducer = C::Reducer; type Result = C::Result;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.