/// `Positions` takes a predicate `predicate` and filters out elements that match, /// yielding their indices. /// /// This struct is created by the [`positions()`] method on [`IndexedParallelIterator`] /// /// [`positions()`]: trait.IndexedParallelIterator.html#method.positions /// [`IndexedParallelIterator`]: trait.IndexedParallelIterator.html #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[derive(Clone)] pubstruct Positions<I: IndexedParallelIterator, P> {
base: I,
predicate: P,
}
impl<F, P, T> Folder<T> for PositionsFolder<'_, F, P> where
F: Folder<usize>,
P: Fn(T) -> bool,
{ type Result = F::Result;
fn consume(mutself, item: T) -> Self { let index = self.offset; self.offset += 1; if (self.predicate)(item) { self.base = self.base.consume(index);
} self
}
// This cannot easily specialize `consume_iter` to be better than // the default, because that requires checking `self.base.full()` // during a call to `self.base.consume_iter()`. (#632)
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.