Struct embedded_time::fraction::Fraction [−][src]
pub struct Fraction(_);
Expand description
Implementations
impl Fraction
[src]
impl Fraction
[src]pub const fn new(numerator: u32, denominator: u32) -> Self
[src]
pub const fn new(numerator: u32, denominator: u32) -> Self
[src]Construct a new Fraction
.
A reduction is not performed. Also there is no check for a denominator of 0
. If these
features are needed, use Fraction::new_reduce()
pub const fn denominator(&self) -> &u32
[src]
pub const fn denominator(&self) -> &u32
[src]Return the denominator of the fraction
impl Fraction
[src]
impl Fraction
[src]pub fn new_reduce(
numerator: u32,
denominator: u32
) -> Result<Self, ConversionError>
[src]
pub fn new_reduce(
numerator: u32,
denominator: u32
) -> Result<Self, ConversionError>
[src]Construct a new Fraction
.
A reduction and denominator == 0
check are performed.
Errors
ConversionError::DivByZero
: A 0
denominator was detected
pub fn to_integer(&self) -> u32
[src]
pub fn to_integer(&self) -> u32
[src]Returns the value truncated to an integer
pub fn from_integer(value: u32) -> Self
[src]
pub fn from_integer(value: u32) -> Self
[src]Constructs a Fraction
from an integer.
Equivalent to Fraction::new(value,1)
.
pub fn checked_mul(&self, v: &Self) -> Option<Self>
[src]
pub fn checked_mul(&self, v: &Self) -> Option<Self>
[src]pub fn checked_div(&self, v: &Self) -> Option<Self>
[src]
pub fn checked_div(&self, v: &Self) -> Option<Self>
[src]Trait Implementations
impl Ord for Fraction
[src]
impl Ord for Fraction
[src]impl PartialOrd<Fraction> for Fraction
[src]
impl PartialOrd<Fraction> for Fraction
[src]fn partial_cmp(&self, other: &Fraction) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Fraction) -> 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