pub trait Merge: Default {
// Required method
fn merge(&mut self, other: Self);
}Expand description
A trait representing a merge operation (monoid) over values of the same type.
Types implementing Merge must also implement Default, which serves as the identity element.
The merge method combines other into self, consuming other.
Implementations should respect monoid laws:
- left identity:
Default::default().merge(x)yieldsx(up to equivalence) - right identity:
x.merge(Default::default())yieldsx(up to equivalence) - associativity:
(x.merge(y)).merge(z)yields the same result asx.merge(y.merge(z)).
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.