Skip to main content

ReduceOperator

Trait ReduceOperator 

Source
pub trait ReduceOperator:
    Send
    + Sync
    + 'static {
    type Acc: Clone + Send + Sync + 'static;
    type Item: Clone + Send + Sync + 'static;
    type Result;

    // Required methods
    fn identity(&self) -> Self::Acc;
    fn fold(&self, acc: Self::Acc, item: Self::Item) -> Self::Acc;
    fn combine(&self, left: Self::Acc, right: Self::Acc) -> Self::Acc;
    fn finalize(&self, acc: Self::Acc) -> Self::Result;
}
Expand description

Reduce with a custom operator struct for more complex reductions.

The operator must provide identity, combine, and finalize methods.

Required Associated Types§

Source

type Acc: Clone + Send + Sync + 'static

The accumulator type.

Source

type Item: Clone + Send + Sync + 'static

The input element type.

Source

type Result

The final result type.

Required Methods§

Source

fn identity(&self) -> Self::Acc

Identity element for the accumulator.

Source

fn fold(&self, acc: Self::Acc, item: Self::Item) -> Self::Acc

Fold a single item into the accumulator.

Source

fn combine(&self, left: Self::Acc, right: Self::Acc) -> Self::Acc

Combine two accumulators.

Source

fn finalize(&self, acc: Self::Acc) -> Self::Result

Convert the final accumulator to the result.

Implementors§