Struct dice::Ratio
[−]
[src]
pub struct Ratio { /* fields omitted */ }
A ratio between two integers.
Methods
impl Ratio
[src]
fn zero() -> Ratio
Returns a Ratio
with the value 0
.
fn new(numerator: i128, denominator: i128) -> Self
fn numerator(&self) -> i128
Returns the numerator part of this ratio.
fn denominator(&self) -> i128
Returns the denominator part of this ratio.
fn percentage(&self, precision: usize) -> String
Returns a string representing this ratio as a percentage.
fn real(&self, precision: usize) -> String
Returns a string representing this ratio as a real number.
fn checked_add(&self, other: Ratio) -> Option<Ratio>
Returns the sum of this ratio and the supplied ratio unless overflow occurs.
fn checked_div(&self, other: Ratio) -> Option<Ratio>
Returns the quotient of this ratio and the supplied ratio unless overflow occurs.
fn checked_mul(&self, other: Ratio) -> Option<Ratio>
Returns the product of this ratio and the supplied ratio unless overflow occurs.
fn checked_sub(&self, other: Ratio) -> Option<Ratio>
Returns the difference of this ratio and the supplied ratio unless overflow occurs.
Trait Implementations
impl Copy for Ratio
[src]
impl Clone for Ratio
[src]
fn clone(&self) -> Ratio
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Debug for Ratio
[src]
impl PartialEq for Ratio
[src]
fn eq(&self, __arg_0: &Ratio) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Ratio) -> bool
This method tests for !=
.
impl Eq for Ratio
[src]
impl Display for Ratio
[src]
fn fmt(&self, formatter: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialOrd for Ratio
[src]
fn partial_cmp(&self, other: &Ratio) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for Ratio
[src]
fn cmp(&self, other: &Ratio) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl Add for Ratio
[src]
type Output = Ratio
The resulting type after applying the +
operator
fn add(self, other: Ratio) -> Self::Output
The method for the +
operator
impl AddAssign for Ratio
[src]
fn add_assign(&mut self, other: Ratio)
The method for the +=
operator
impl Sub for Ratio
[src]
type Output = Ratio
The resulting type after applying the -
operator
fn sub(self, other: Ratio) -> Self::Output
The method for the -
operator
impl SubAssign for Ratio
[src]
fn sub_assign(&mut self, other: Ratio)
The method for the -=
operator
impl Mul for Ratio
[src]
type Output = Ratio
The resulting type after applying the *
operator
fn mul(self, other: Ratio) -> Self::Output
The method for the *
operator
impl MulAssign for Ratio
[src]
fn mul_assign(&mut self, other: Ratio)
The method for the *=
operator
impl Div for Ratio
[src]
type Output = Ratio
The resulting type after applying the /
operator
fn div(self, other: Ratio) -> Self::Output
The method for the /
operator
impl DivAssign for Ratio
[src]
fn div_assign(&mut self, other: Ratio)
The method for the /=
operator