Struct rational::Rational[][src]

pub struct Rational { /* fields omitted */ }

Implementations

impl Rational[src]

pub fn new<N, D>(numerator: N, denominator: D) -> Self where
    Rational: From<N>,
    Rational: From<D>, 
[src]

Construct a new Rational.

Panics

  • If the resulting denominator is 0.

pub fn new_checked<T>(numerator: T, denominator: T) -> Option<Self> where
    Rational: From<T>, 
[src]

Construct a new Rational, returning None if the denominator is 0.

pub fn numerator(&self) -> i128[src]

Get the numerator in this Rational.

pub fn denominator(&self) -> i128[src]

Get the denominator in this Rational.

pub fn inverse_checked(self) -> Option<Self>[src]

Returns the inverse of this Rational, or None if the denominator of the inverse is 0.

pub fn inverse(self) -> Self[src]

Returns the inverse of this Rational.

Panics

  • If the denominator of the inverse is 0.

pub fn decimal_value(self) -> f64[src]

Returns the decimal value of this Rational. Equivalent to f64::from(self).

Trait Implementations

impl<T> Add<T> for Rational where
    Rational: From<T>, 
[src]

type Output = Self

The resulting type after applying the + operator.

impl<T> AddAssign<T> for Rational where
    Rational: From<T>, 
[src]

impl Clone for Rational[src]

impl Copy for Rational[src]

impl Debug for Rational[src]

impl Display for Rational[src]

impl<T> Div<T> for Rational where
    Rational: From<T>, 
[src]

type Output = Self

The resulting type after applying the / operator.

impl<T> DivAssign<T> for Rational where
    Rational: From<T>, 
[src]

impl Eq for Rational[src]

impl From<i128> for Rational[src]

impl From<i16> for Rational[src]

impl From<i32> for Rational[src]

impl From<i64> for Rational[src]

impl From<i8> for Rational[src]

impl From<isize> for Rational[src]

impl From<u16> for Rational[src]

impl From<u32> for Rational[src]

impl From<u64> for Rational[src]

impl From<u8> for Rational[src]

impl<T> Mul<T> for Rational where
    Rational: From<T>, 
[src]

type Output = Self

The resulting type after applying the * operator.

impl<T> MulAssign<T> for Rational where
    Rational: From<T>, 
[src]

impl Neg for Rational[src]

type Output = Self

The resulting type after applying the - operator.

impl Ord for Rational[src]

impl PartialEq<Rational> for Rational[src]

impl PartialOrd<Rational> for Rational[src]

impl<T> Sub<T> for Rational where
    Rational: From<T>, 
[src]

type Output = Self

The resulting type after applying the - operator.

impl<T> SubAssign<T> for Rational where
    Rational: From<T>, 
[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.