Skip to main content

Factor

Trait Factor 

Source
pub trait Factor
where Self: Copy + Mul<Output = Self> + Div<Output = Self> + PartialEq + Eq + Default,
{ const ZERO: Self; // Required method fn gcd(self, other: Self) -> Self; // Provided methods fn lcm(self, other: Self) -> Self { ... } fn gcd_lcm(self, other: Self) -> (Self, Self) { ... } fn gcd_bulk(r: impl IntoIterator<Item = Self>) -> Self { ... } fn lcm_bulk(r: impl IntoIterator<Item = Self>) -> Self { ... } fn signed( f: impl Fn(Self, Self) -> Self, r: impl IntoIterator<Item = Self>, ) -> Self where Self: Neg<Output = Self> + PartialOrd + Ord { ... } }
Expand description

Finds the greatest common divisor (GCD) and the least common multiple (LCM).

Required Associated Constants§

Source

const ZERO: Self

The zero constant.

Required Methods§

Source

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

Finds the greatest common divisor (GCD) of self and other.

Provided Methods§

Source

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

Finds the least common multiple (LCM) of self and other.

Calls Self::gcd_lcm() and discards GCD.

Source

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

Returns (Self::gcd(), Self::lcm()) of self and other.

Calls Self::gcd() to find LCM.

Source

fn gcd_bulk(r: impl IntoIterator<Item = Self>) -> Self

Finds the GCD of iterator over Self.

Source

fn lcm_bulk(r: impl IntoIterator<Item = Self>) -> Self

Finds the LCM of iterator over Self.

Source

fn signed( f: impl Fn(Self, Self) -> Self, r: impl IntoIterator<Item = Self>, ) -> Self
where Self: Neg<Output = Self> + PartialOrd + Ord,

Finds the Self::gcd or Self::lcm and the predominant sign of iterator over 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 Factor for i32

Source§

const ZERO: Self = 0

Source§

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

Source§

impl Factor for u32

Source§

const ZERO: Self = 0

Source§

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

Implementors§

Source§

impl Factor for Rational

Source§

const ZERO: Self = Self::ZERO