pub struct Currency { /* private fields */ }Expand description
How a money column spells its amounts: the symbol, where it goes, the decimals, and whether the field stores minor units.
use tablo_core::Currency;
assert_eq!(Currency::USD.format(1234.5), "$1,234.50");
assert_eq!(Currency::EUR.format(1234.5), "€1,234.50");
assert_eq!(
Currency::new("CHF").symbol_after().format(-3.0),
"-3.00 CHF"
);
assert_eq!(Currency::USD.minor_units().format(123_456), "$1,234.56");format spells English; a column spells the request’s locale through
format_in: its catalog’s separators, 1 234,50, and its side for the
symbol, 1 234,50 € in French, unless symbol_before or
symbol_after fixes it.
Implementations§
Source§impl Currency
impl Currency
Sourcepub const fn new(symbol: &'static str) -> Self
pub const fn new(symbol: &'static str) -> Self
A currency spelled with symbol before the amount and two decimals.
Sourcepub const fn symbol_after(self) -> Self
pub const fn symbol_after(self) -> Self
Put the symbol after the amount, separated by a space, in every locale.
Sourcepub const fn symbol_before(self) -> Self
pub const fn symbol_before(self) -> Self
Put the symbol before the amount in every locale, as English does.
Sourcepub const fn minor_units(self) -> Self
pub const fn minor_units(self) -> Self
Read the field as minor units, cents for a two-decimal currency: 123456 is 1,234.56.
Trait Implementations§
impl Copy for Currency
impl Eq for Currency
impl StructuralPartialEq for Currency
Auto Trait Implementations§
impl Forget for Currency
impl Freeze for Currency
impl RefUnwindSafe for Currency
impl Send for Currency
impl Sync for Currency
impl Unpin for Currency
impl UnsafeUnpin for Currency
impl UnwindSafe for Currency
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.