pub struct Money { /* private fields */ }Expand description
A money value with an explicit currency and checked decimal amount.
Implementations§
Source§impl Money
impl Money
Sourcepub const fn new(currency: CurrencyCode, amount: Decimal) -> Self
pub const fn new(currency: CurrencyCode, amount: Decimal) -> Self
Creates a money value from an already validated currency and decimal amount.
Sourcepub const fn currency(self) -> CurrencyCode
pub const fn currency(self) -> CurrencyCode
Returns the currency identifier.
Sourcepub fn checked_add(self, other: Self) -> Result<Self, MoneyError>
pub fn checked_add(self, other: Self) -> Result<Self, MoneyError>
Adds two money values with identical currency and decimal type.
Sourcepub fn checked_sub(self, other: Self) -> Result<Self, MoneyError>
pub fn checked_sub(self, other: Self) -> Result<Self, MoneyError>
Subtracts two money values with identical currency and decimal type.
Sourcepub fn checked_cmp(self, other: Self) -> Result<Ordering, MoneyError>
pub fn checked_cmp(self, other: Self) -> Result<Ordering, MoneyError>
Compares two values with identical currency and decimal type.
Trait Implementations§
impl Copy for Money
impl Eq for Money
Source§impl PartialOrd for Money
impl PartialOrd for Money
impl StructuralPartialEq for Money
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