Trait stats::Commute

source ·
pub trait Commute: Sized {
    fn merge(&mut self, other: Self);

    fn consume<I: Iterator<Item = Self>>(&mut self, other: I) { ... }
}
Expand description

Defines an interface for types that have an identity and can be commuted.

The value returned by Default::default must be its identity with respect to the merge operation.

Required Methods§

Merges the value other into self.

Provided Methods§

Merges the values in the iterator into self.

Examples found in repository?
src/lib.rs (line 124)
120
121
122
123
124
125
126
127
128
pub fn merge_all<T: Commute, I: Iterator<Item = T>>(mut it: I) -> Option<T> {
    it.next().map_or_else(
        || None,
        |mut init| {
            init.consume(it);
            Some(init)
        },
    )
}

Implementations on Foreign Types§

Implementors§