pub struct Money { /* private fields */ }Expand description
An amount in a currency, counted in the currency’s smallest unit: {"currency": "EUR", "base_units": "-1240"}
is −12.40 euros.
The count is exact and has one written form only – an integer as a string ("-1240"), never a JSON number –
so the same amount always has the same bytes and the same hash. Its magnitude is at most
Money::MAX_BASE_UNITS. Reading, checking and summing amounts never needs the currency’s definition.
Implementations§
Source§impl Money
impl Money
Sourcepub const MAX_BASE_UNITS: i128
pub const MAX_BASE_UNITS: i128
The largest magnitude of an amount in base units: 10^38 − 1. Every implementation can represent it.
Sourcepub fn new(base_units: i128, currency: Currency) -> Option<Self>
pub fn new(base_units: i128, currency: Currency) -> Option<Self>
base_units of the currency’s smallest unit; None if the magnitude is above Self::MAX_BASE_UNITS.
Sourcepub fn base_units(&self) -> i128
pub fn base_units(&self) -> i128
The amount in the currency’s smallest unit; its sign is given by its use (see crate::Posting).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Money
impl<'de> Deserialize<'de> for Money
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
impl Eq 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