Struct rational::Rational [−][src]
pub struct Rational { /* fields omitted */ }
Expand description
A rational number (a fraction of two integers).
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]
pub fn new<N, D>(numerator: N, denominator: D) -> Self where
Rational: From<N>,
Rational: From<D>,
[src]pub fn new_checked<N, D>(numerator: N, denominator: D) -> Option<Self> where
Rational: From<N>,
Rational: From<D>,
[src]
pub fn new_checked<N, D>(numerator: N, denominator: D) -> Option<Self> where
Rational: From<N>,
Rational: From<D>,
[src]Construct a new Rational, returning None
if the denominator is 0.
pub fn denominator(&self) -> i128
[src]
pub fn denominator(&self) -> i128
[src]Get the denominator in this Rational
.
pub fn inverse_checked(self) -> Option<Self>
[src]
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 decimal_value(self) -> f64
[src]
pub fn decimal_value(self) -> f64
[src]Returns the decimal value of this Rational
.
Equivalent to f64::from(self)
.
pub fn checked_add<T>(self, other: T) -> Option<Self> where
Self: From<T>,
[src]
Self: From<T>,
pub fn checked_mul<T>(self, other: T) -> Option<Self> where
Self: From<T>,
[src]
Self: From<T>,
pub fn checked_sub<T>(self, other: T) -> Option<Self> where
Self: From<T>,
[src]
Self: From<T>,
pub fn checked_div<T>(self, other: T) -> Option<Self> where
Self: From<T>,
[src]
Self: From<T>,
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]
fn add_assign(&mut self, rhs: T)
[src]Performs the +=
operation. Read more
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]
fn div_assign(&mut self, rhs: T)
[src]Performs the /=
operation. Read more
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]
fn mul_assign(&mut self, rhs: T)
[src]Performs the *=
operation. Read more
impl Ord for Rational
[src]
impl Ord for Rational
[src]impl PartialOrd<Rational> for Rational
[src]
impl PartialOrd<Rational> for Rational
[src]fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T> SubAssign<T> for Rational where
Rational: From<T>,
[src]
impl<T> SubAssign<T> for Rational where
Rational: From<T>,
[src]fn sub_assign(&mut self, rhs: T)
[src]
fn sub_assign(&mut self, rhs: T)
[src]Performs the -=
operation. Read more
impl Copy for Rational
[src]
impl Eq for Rational
[src]
Auto Trait Implementations
impl RefUnwindSafe for Rational
impl Send for Rational
impl Sync for Rational
impl Unpin for Rational
impl UnwindSafe for Rational
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more