Trait rayon::iter::plumbing::Folder

source ·
pub trait Folder<Item>: Sized {
    type Result;

    // Required methods
    fn consume(self, item: Item) -> Self;
    fn complete(self) -> Self::Result;
    fn full(&self) -> bool;

    // Provided method
    fn consume_iter<I>(self, iter: I) -> Self
       where I: IntoIterator<Item = Item> { ... }
}
Expand description

The Folder trait encapsulates the standard fold operation. It can be fed many items using the consume method. At the end, once all items have been consumed, it can then be converted (using complete) into a final value.

Required Associated Types§

source

type Result

The type of result that will ultimately be produced by the folder.

Required Methods§

source

fn consume(self, item: Item) -> Self

Consume next item and return new sequential state.

source

fn complete(self) -> Self::Result

Finish consuming items, produce final result.

source

fn full(&self) -> bool

Hint whether this Folder would like to stop processing further items, e.g. if a search has been completed.

Provided Methods§

source

fn consume_iter<I>(self, iter: I) -> Self
where I: IntoIterator<Item = Item>,

Consume items from the iterator until full, and return new sequential state.

This method is optional. The default simply iterates over iter, invoking consume and checking after each iteration whether full returns false.

The main reason to override it is if you can provide a more specialized, efficient implementation.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Folder<char> for ListStringFolder

source§

impl<'a, T, C> Folder<T> for PanicFuseFolder<'a, C>
where C: Folder<T>,

§

type Result = <C as Folder<T>>::Result

source§

impl<'a, T, F> Folder<&'a T> for ClonedFolder<F>
where F: Folder<T>, T: 'a + Clone,

§

type Result = <F as Folder<T>>::Result

source§

impl<'a, T, F> Folder<&'a T> for CopiedFolder<F>
where F: Folder<T>, T: 'a + Copy,

§

type Result = <F as Folder<T>>::Result

source§

impl<'a, T, OP, FA, FB> Folder<T> for UnzipFolder<'a, OP, FA, FB>
where OP: UnzipOp<T>, FA: Folder<OP::Left>, FB: Folder<OP::Right>,

§

type Result = (<FA as Folder<<OP as UnzipOp<T>>::Left>>::Result, <FB as Folder<<OP as UnzipOp<T>>::Right>>::Result)

source§

impl<'c, T: Send + 'c> Folder<T> for CollectResult<'c, T>

§

type Result = CollectResult<'c, T>

source§

impl<'f, F, T> Folder<T> for ForEachConsumer<'f, F>
where F: Fn(T) + Sync,

§

type Result = ()

source§

impl<'f, T, C> Folder<Option<T>> for WhileSomeFolder<'f, C>
where C: Folder<T>,

§

type Result = <C as Folder<T>>::Result

source§

impl<'f, T, C> Folder<T> for SkipAnyFolder<'f, C>
where C: Folder<T>,

§

type Result = <C as Folder<T>>::Result

source§

impl<'f, T, C> Folder<T> for TakeAnyFolder<'f, C>
where C: Folder<T>,

§

type Result = <C as Folder<T>>::Result

source§

impl<'f, T, C, F> Folder<T> for InspectFolder<'f, C, F>
where C: Folder<T>, F: Fn(&T),

§

type Result = <C as Folder<T>>::Result

source§

impl<'f, T, C, F> Folder<T> for UpdateFolder<'f, C, F>
where C: Folder<T>, F: Fn(&mut T),

§

type Result = <C as Folder<T>>::Result

source§

impl<'f, T, R, C, F> Folder<T> for MapFolder<'f, C, F>
where C: Folder<F::Output>, F: Fn(T) -> R,

§

type Result = <C as Folder<<F as FnOnce(T)>::Output>>::Result

source§

impl<'f, T, U, C, F> Folder<T> for FlatMapFolder<'f, C, F, C::Result>
where C: UnindexedConsumer<U::Item>, F: Fn(T) -> U + Sync, U: IntoParallelIterator,

source§

impl<'f, T, U, C, F> Folder<T> for FlatMapIterFolder<'f, C, F>
where C: Folder<U::Item>, F: Fn(T) -> U, U: IntoIterator,

§

type Result = <C as Folder<<U as IntoIterator>::Item>>::Result

source§

impl<'f, T, U, R, C, F> Folder<T> for MapWithFolder<'f, C, U, F>
where C: Folder<R>, F: Fn(&mut U, T) -> R,

§

type Result = <C as Folder<R>>::Result

source§

impl<'p, C, P, T> Folder<T> for FilterFolder<'p, C, P>
where C: Folder<T>, P: Fn(&T) -> bool + 'p,

§

type Result = <C as Folder<T>>::Result

source§

impl<'p, P: 'p + Fn(&T) -> bool, T> Folder<T> for rayon::iter::find_first_last::FindFolder<'p, T, P>

§

type Result = Option<T>

source§

impl<'p, T, C, P> Folder<T> for SkipAnyWhileFolder<'p, C, P>
where C: Folder<T>, P: Fn(&T) -> bool + 'p,

§

type Result = <C as Folder<T>>::Result

source§

impl<'p, T, C, P> Folder<T> for TakeAnyWhileFolder<'p, C, P>
where C: Folder<T>, P: Fn(&T) -> bool + 'p,

§

type Result = <C as Folder<T>>::Result

source§

impl<'p, T, P> Folder<T> for rayon::iter::find::FindFolder<'p, T, P>
where P: Fn(&T) -> bool + 'p,

§

type Result = Option<T>

source§

impl<'p, T, U, C, P> Folder<T> for FilterMapFolder<'p, C, P>
where C: Folder<U>, P: Fn(T) -> Option<U> + Sync + 'p,

§

type Result = <C as Folder<U>>::Result

source§

impl<'r, C, ID, F, T> Folder<T> for FoldFolder<'r, C, ID, F>
where C: Folder<ID>, F: Fn(ID, T) -> ID + Sync,

§

type Result = <C as Folder<ID>>::Result

source§

impl<'r, C, U, F, T> Folder<T> for TryFoldFolder<'r, C, U, F>
where C: Folder<U>, F: Fn(U::Output, T) -> U + Sync, U: Try,

§

type Result = <C as Folder<U>>::Result

source§

impl<'r, R, T> Folder<T> for ReduceFolder<'r, R, T>
where R: Fn(T, T) -> T,

§

type Result = T

source§

impl<'r, R, T> Folder<T> for TryReduceFolder<'r, R, T>
where R: Fn(T::Output, T::Output) -> T, T: Try,

§

type Result = T

source§

impl<'r, R, T> Folder<T> for TryReduceWithFolder<'r, R, T>
where R: Fn(T::Output, T::Output) -> T, T: Try,

§

type Result = Option<T>

source§

impl<C, T> Folder<T> for IntersperseFolder<C, T>
where C: Folder<T>, T: Clone,

§

type Result = <C as Folder<T>>::Result

source§

impl<F, P, T> Folder<T> for PositionsFolder<'_, F, P>
where F: Folder<usize>, P: Fn(T) -> bool,

§

type Result = <F as Folder<usize>>::Result

source§

impl<P, T> Folder<T> for ProductFolder<P>
where P: Product<T> + Product,

§

type Result = P

source§

impl<S, T> Folder<T> for SumFolder<S>
where S: Sum<T> + Sum,

§

type Result = S

source§

impl<T> Folder<T> for ListFolder<T>

source§

impl<T> Folder<T> for ListVecFolder<T>

source§

impl<T> Folder<T> for NoopConsumer

§

type Result = ()

source§

impl<T, C> Folder<T> for FlattenFolder<C, C::Result>

source§

impl<T, C> Folder<T> for FlattenIterFolder<C>
where C: Folder<T::Item>, T: IntoIterator,

§

type Result = <C as Folder<<T as IntoIterator>::Item>>::Result