[][src]Trait libpuri::Monoid

pub trait Monoid {
    pub const ID: Self;

    pub fn op(&self, rhs: &Self) -> Self;
}

Trait for associative binary operations with an identity element.

Monoid requires that the following property holds:

This example is not tested
// The operation * is associative.
(a * b) * c == a * (b * c)

// There exists an identity element.
a * id == id * a == a

This property cannot be checked by the compiler so the implementer should verify it by themself.

Associated Constants

pub const ID: Self[src]

The identity element.

Loading content...

Required methods

pub fn op(&self, rhs: &Self) -> Self[src]

An associative binary operator on monoid elements.

Loading content...

Implementors

Loading content...