Struct Money
pub struct Money {
amount: f64,
currency: Currency,
}Expand description
A currency-tagged amount.
Fields§
§amount: f64§currency: CurrencyImplementations§
§impl Money
impl Money
fn require_same(&self, other: &Money) -> Result<(), MoneyError>
pub fn add(&self, other: &Money) -> Result<Money, MoneyError>
pub fn add(&self, other: &Money) -> Result<Money, MoneyError>
Adds two same-currency amounts.
§Errors
MoneyError naming both currencies when they differ. Amounts in
different currencies do not add, so the sum is refused rather than
produced in mixed units.
pub fn sub(&self, other: &Money) -> Result<Money, MoneyError>
pub fn sub(&self, other: &Money) -> Result<Money, MoneyError>
Subtracts two same-currency amounts.
§Errors
As add: MoneyError naming both currencies when they
differ.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Money
impl RefUnwindSafe for Money
impl Send for Money
impl Sync for Money
impl Unpin for Money
impl UnsafeUnpin for Money
impl UnwindSafe for Money
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