Skip to main content

LocalInteger

Trait LocalInteger 

Source
pub trait LocalInteger:
    Sized
    + Eq
    + LocalNum {
    // Required methods
    fn gcd(&self, other: &Self) -> Self;
    fn lcm(&self, other: &Self) -> Self;
    fn is_multiple_of(&self, other: &Self) -> bool;

    // Provided methods
    fn gcd_lcm(&self, other: &Self) -> (Self, Self) { ... }
    fn div_rem(self, other: Self) -> (Self, Self)
       where Self: Clone { ... }
    fn dec(&mut self)
       where Self: Clone { ... }
    fn inc(&mut self)
       where Self: Clone { ... }
}
Expand description

A LocalNum that allows division, remainder, GCD, and LCM

This is something like a Euclidean domain, but do not expect it to be mathematically equivalent.

Required Methods§

Source

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

Greatest Common Divisor (GCD)

Source

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

Lowest Common Multiple (LCM)

Source

fn is_multiple_of(&self, other: &Self) -> bool

Returns true if self is a multiple of other

Provided Methods§

Source

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

Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) together

Potentially more efficient than calling gcd and lcm individually for identical inputs.

Source

fn div_rem(self, other: Self) -> (Self, Self)
where Self: Clone,

Simultaneous truncated integer division and modulus, returns (quotient, remainder)

Source

fn dec(&mut self)
where Self: Clone,

Decrements self by one

Source

fn inc(&mut self)
where Self: Clone,

Increments self by one

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.

Implementors§