/// `TryFold` is an iterator that applies a function over an iterator producing a single value. /// This struct is created by the [`try_fold()`] method on [`ParallelIterator`] /// /// [`try_fold()`]: trait.ParallelIterator.html#method.try_fold /// [`ParallelIterator`]: trait.ParallelIterator.html #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[derive(Clone)] pubstruct TryFold<I, U, ID, F> {
base: I,
identity: ID,
fold_op: F,
marker: PhantomData<U>,
}
impl<'r, U, T, C, ID, F> Consumer<T> for TryFoldConsumer<'r, U, C, ID, F> where
C: Consumer<U>,
F: Fn(U::Output, T) -> U + Sync,
ID: Fn() -> U::Output + Sync,
U: Try + Send,
{ type Folder = TryFoldFolder<'r, C::Folder, U, F>; type Reducer = C::Reducer; type Result = C::Result;
impl<U, I, F> TryFoldWith<I, U, F> where
I: ParallelIterator,
F: Fn(U::Output, I::Item) -> U + Sync,
U: Try + Send,
U::Output: Clone + Send,
{ pub(super) fn new(base: I, item: U::Output, fold_op: F) -> Self {
TryFoldWith {
base,
item,
fold_op,
}
}
}
/// `TryFoldWith` is an iterator that applies a function over an iterator producing a single value. /// This struct is created by the [`try_fold_with()`] method on [`ParallelIterator`] /// /// [`try_fold_with()`]: trait.ParallelIterator.html#method.try_fold_with /// [`ParallelIterator`]: trait.ParallelIterator.html #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[derive(Clone)] pubstruct TryFoldWith<I, U: Try, F> {
base: I,
item: U::Output,
fold_op: F,
}
impl<'r, U, T, C, F> Consumer<T> for TryFoldWithConsumer<'r, C, U, F> where
C: Consumer<U>,
F: Fn(U::Output, T) -> U + Sync,
U: Try + Send,
U::Output: Clone + Send,
{ type Folder = TryFoldFolder<'r, C::Folder, U, F>; 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.