Trait Fraction

Source
pub trait Fraction<T>: Sized {
    // Required methods
    fn numerator(&self) -> T;
    fn denominator(&self) -> T;
    fn inv(&self) -> Option<Self>;
}
Expand description

A fraction p/q with integers p and q.

p is called the numerator and q is called the denominator.

Required Methods§

Source

fn numerator(&self) -> T

Returns the numerator p

Source

fn denominator(&self) -> T

Returns the denominator q

Source

fn inv(&self) -> Option<Self>

Returns the multiplicative inverse q/p for fraction p/q.

If p is zero, None is returned.

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<T: Copy + From<u8> + PartialEq> Fraction<T> for (T, T)

Source§

fn numerator(&self) -> T

Source§

fn denominator(&self) -> T

Source§

fn inv(&self) -> Option<Self>

Implementors§