pub trait Ring:
Sized
+ Clone
+ PartialEq
+ Debug
+ Add<Output = Self>
+ Sub<Output = Self>
+ Mul<Output = Self>
+ Neg<Output = Self> {
// Required methods
fn zero() -> Self;
fn one() -> Self;
fn is_zero(&self) -> bool;
fn is_one(&self) -> bool;
// Provided methods
fn wrapping_add(&self, other: &Self) -> Self { ... }
fn wrapping_sub(&self, other: &Self) -> Self { ... }
fn wrapping_mul(&self, other: &Self) -> Self { ... }
}Expand description
Ring: addition, subtraction, multiplication with identity elements
A ring is an algebraic structure with two binary operations (+ and *) satisfying these properties:
- Additive identity: exists 0 such that a + 0 = a
- Multiplicative identity: exists 1 such that a * 1 = a
- Additive inverse: for all a, exists -a such that a + (-a) = 0
- Associative: (a + b) + c = a + (b + c), (a * b) * c = a * (b * c)
- Distributive: a * (b + c) = a * b + a * c
Required Methods§
fn zero() -> Self
fn one() -> Self
fn is_zero(&self) -> bool
fn is_one(&self) -> bool
Provided Methods§
fn wrapping_add(&self, other: &Self) -> Self
fn wrapping_sub(&self, other: &Self) -> Self
fn wrapping_mul(&self, other: &Self) -> Self
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.