pub trait Monoid {
const ID: Self;
// Required method
fn op(&self, rhs: &Self) -> Self;
}
Expand description
Trait for associative binary operations with an identity element.
Monoid requires that the following property holds:
ⓘ
// 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.
Required Associated Constants§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.