Ring

Trait Ring 

Source
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§

Source

fn zero() -> Self

Source

fn one() -> Self

Source

fn is_zero(&self) -> bool

Source

fn is_one(&self) -> bool

Provided Methods§

Source

fn wrapping_add(&self, other: &Self) -> Self

Source

fn wrapping_sub(&self, other: &Self) -> Self

Source

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.

Implementations on Foreign Types§

Source§

impl Ring for i64

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn is_zero(&self) -> bool

Source§

fn is_one(&self) -> bool

Source§

fn wrapping_add(&self, other: &Self) -> Self

Source§

fn wrapping_sub(&self, other: &Self) -> Self

Source§

fn wrapping_mul(&self, other: &Self) -> Self

Source§

impl Ring for Ratio<i64>

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn is_zero(&self) -> bool

Source§

fn is_one(&self) -> bool

Implementors§