pub struct ExchangeRate { /* private fields */ }
Expand description
An exchange rate between two quantities. This is never 0, and the exchange rate should also never be infinite.
Implementations§
source§impl ExchangeRate
impl ExchangeRate
sourcepub fn new(numerator: u64, denominator: u64) -> Option<Self>
pub fn new(numerator: u64, denominator: u64) -> Option<Self>
Attempt to construct an exchange rate from a numerator and denominator. The numerator and denominator must both be non-zero, and they have to be in reduced form.
sourcepub const fn new_unchecked(numerator: u64, denominator: u64) -> Self
pub const fn new_unchecked(numerator: u64, denominator: u64) -> Self
Construct an unchecked exchange rate from a numerator and denominator. The numerator and denominator must both be non-zero, and they have to be in reduced form.
sourcepub const fn denominator(&self) -> u64
pub const fn denominator(&self) -> u64
Get the denominator. This is never 0.
Trait Implementations§
source§impl Clone for ExchangeRate
impl Clone for ExchangeRate
source§fn clone(&self) -> ExchangeRate
fn clone(&self) -> ExchangeRate
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ExchangeRate
impl Debug for ExchangeRate
source§impl Deserial for ExchangeRate
impl Deserial for ExchangeRate
source§impl<'de> Deserialize<'de> for ExchangeRate
impl<'de> Deserialize<'de> for ExchangeRate
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl FromStr for ExchangeRate
impl FromStr for ExchangeRate
source§impl PartialEq for ExchangeRate
impl PartialEq for ExchangeRate
source§fn eq(&self, other: &ExchangeRate) -> bool
fn eq(&self, other: &ExchangeRate) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Serial for ExchangeRate
impl Serial for ExchangeRate
source§impl Serialize for ExchangeRate
impl Serialize for ExchangeRate
source§impl TryFrom<ExchangeRateJSON> for ExchangeRate
impl TryFrom<ExchangeRateJSON> for ExchangeRate
§type Error = ExchangeRateConversionError
type Error = ExchangeRateConversionError
The type returned in the event of a conversion error.
impl Copy for ExchangeRate
impl Eq for ExchangeRate
impl StructuralPartialEq for ExchangeRate
Auto Trait Implementations§
impl Freeze for ExchangeRate
impl RefUnwindSafe for ExchangeRate
impl Send for ExchangeRate
impl Sync for ExchangeRate
impl Unpin for ExchangeRate
impl UnwindSafe for ExchangeRate
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more