pub struct LogosMoney(pub Money);Expand description
Money for the compiled tier — an exact amount in a currency, mirroring base::Money. + −
require the SAME currency (a runtime-panic backstop; the type checker rejects mismatches first),
× ÷ scale by an exact number, and a same-currency ÷ is the dimensionless ratio.
Tuple Fields§
§0: MoneyImplementations§
Source§impl LogosMoney
impl LogosMoney
Sourcepub fn of(amount: LogosDecimal, code: &str) -> Self
pub fn of(amount: LogosDecimal, code: &str) -> Self
Money of a Decimal amount in the named currency. Panics on an unknown currency, which the
front-end has already rejected before codegen.
Sourcepub fn from_i64(amount: i64, code: &str) -> Self
pub fn from_i64(amount: i64, code: &str) -> Self
Money of an integer amount — the 5 USD case (codegen passes the literal directly).
pub fn add(&self, other: &LogosMoney) -> LogosMoney
pub fn sub(&self, other: &LogosMoney) -> LogosMoney
Sourcepub fn scale_int(&self, k: i64) -> LogosMoney
pub fn scale_int(&self, k: i64) -> LogosMoney
Scale by an integer (19.99 USD × 3), re-quantised to the currency.
Sourcepub fn scale_decimal(&self, k: &LogosDecimal) -> LogosMoney
pub fn scale_decimal(&self, k: &LogosDecimal) -> LogosMoney
Scale by an exact decimal (price × 1.5), re-quantised to the currency.
Sourcepub fn div_int(&self, k: i64) -> LogosMoney
pub fn div_int(&self, k: i64) -> LogosMoney
Divide by an integer (split a bill), re-quantised to the currency.
Sourcepub fn ratio(&self, other: &LogosMoney) -> LogosRational
pub fn ratio(&self, other: &LogosMoney) -> LogosRational
The exact dimensionless ratio of two same-currency amounts.
Trait Implementations§
Source§impl Clone for LogosMoney
impl Clone for LogosMoney
Source§fn clone(&self) -> LogosMoney
fn clone(&self) -> LogosMoney
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LogosMoney
impl Debug for LogosMoney
Source§impl Display for LogosMoney
impl Display for LogosMoney
Source§impl PartialEq for LogosMoney
impl PartialEq for LogosMoney
Source§impl PartialOrd for LogosMoney
impl PartialOrd for LogosMoney
Source§fn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
Ordered by amount within a currency; across currencies it is incomparable (None).
impl Eq for LogosMoney
Auto Trait Implementations§
impl Freeze for LogosMoney
impl RefUnwindSafe for LogosMoney
impl Send for LogosMoney
impl Sync for LogosMoney
impl Unpin for LogosMoney
impl UnsafeUnpin for LogosMoney
impl UnwindSafe for LogosMoney
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.