pub trait AddMonoid:
Add<Output = Self>
+ AddAssign
+ Zero
+ Clone { }Expand description
Represents an Additive Monoid.
A monoid is an algebraic structure with a single associative binary
operation and an identity element. An additive monoid is one where the
operation is addition (+).
§Mathematical Definition
A set S with a binary operation + is an additive monoid if it satisfies:
- Closure:
a + bis inS. (Implicit in Rust). - Associativity:
(a + b) + c = a + (b + c)for alla, b, cinS. (A property the implementor must uphold). - Identity Element: There exists an element
0inSsuch thata + 0 = 0 + a = afor allainS. (Provided by theZerotrait).
The Clone and AddAssign bounds are included for practical purposes.
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.