Struct rational::Rational [−][src]
pub struct Rational { /* fields omitted */ }
Implementations
impl Rational
[src]
impl Rational
[src]pub fn new<N, D>(numerator: N, denominator: D) -> Self where
Rational: From<N>,
Rational: From<D>,
[src]
Rational: From<N>,
Rational: From<D>,
pub fn new_checked<T>(numerator: T, denominator: T) -> Option<Self> where
Rational: From<T>,
[src]
Rational: From<T>,
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]
pub fn decimal_value(self) -> f64
[src]
Returns the decimal value of this Rational
.
Equivalent to f64::from(self)
.
Trait Implementations
impl<T> AddAssign<T> for Rational where
Rational: From<T>,
[src]
impl<T> AddAssign<T> for Rational where
Rational: From<T>,
[src]fn add_assign(&mut self, rhs: T)
[src]
impl<T> DivAssign<T> for Rational where
Rational: From<T>,
[src]
impl<T> DivAssign<T> for Rational where
Rational: From<T>,
[src]fn div_assign(&mut self, rhs: T)
[src]
impl<T> MulAssign<T> for Rational where
Rational: From<T>,
[src]
impl<T> MulAssign<T> for Rational where
Rational: From<T>,
[src]fn mul_assign(&mut self, rhs: T)
[src]
impl PartialOrd<Rational> for Rational
[src]
impl PartialOrd<Rational> for Rational
[src]Auto Trait Implementations
impl RefUnwindSafe for Rational
impl RefUnwindSafe for Rational
impl UnwindSafe for Rational
impl UnwindSafe for Rational