Skip to main content

Monoid

Trait Monoid 

Source
pub trait Monoid: Default {
    type SourceValue;

    // Required methods
    fn new(value: Self::SourceValue) -> Self;
    fn combine(&self, other: &Self) -> Self;
}
Expand description

Interface for a monoid. The default value must be the identity of the monoid.

Required Associated Types§

Source

type SourceValue

The source value for constructing the monoid.

Required Methods§

Source

fn new(value: Self::SourceValue) -> Self

Creates a monoid from a given value.

Source

fn combine(&self, other: &Self) -> Self

Combines two monoids. This operation must be associative.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§