pub trait Ring:
AbelianGroup
+ MulMonoid
+ Distributive { }Expand description
Represents a Ring in abstract algebra.
A ring is an algebraic structure with two binary operations, addition and
multiplication, that is more general than a Field because it does not
require multiplicative inverses for all non-zero elements.
§Mathematical Definition
A set R is a ring if it satisfies the following laws:
-
Under Addition:
Rforms anAbelianGroup.- Addition is associative:
(a + b) + c = a + (b + c) - Addition is commutative:
a + b = b + a - There is an additive identity
0:a + 0 = a - Every element
ahas an additive inverse-a:a + (-a) = 0
- Addition is associative:
-
Under Multiplication:
Rforms aMulMonoid.- Multiplication is associative:
(a * b) * c = a * (b * c) - There is a multiplicative identity
1:a * 1 = a
- Multiplication is associative:
-
Distributivity: Multiplication distributes over addition.
a * (b + c) = (a * b) + (a * c)(Left distributivity)(a + b) * c = (a * c) + (b * c)(Right distributivity)
This trait combines AbelianGroup and MulMonoid to enforce these properties.
The distributivity law is implicitly assumed to be upheld by the Add and
Mul implementations.
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.