pub struct DisplayMoney(pub Decimal);Expand description
A monetary amount as shown to a user: $ followed by the amount, or the
unlimited_label when the amount is an “unlimited” sentinel.
Display only: the wrapped value is not changed. The formatter’s precision
and width apply to the number only, so format!("{:.2}", DisplayMoney(x))
prints $12.34 for a finite amount and Unlimited for Decimal::MAX.
use optionstratlib_core::model::DisplayMoney;
use positive::Positive;
use rust_decimal_macros::dec;
assert_eq!(format!("{:.2}", DisplayMoney(dec!(12.34))), "$12.34");
assert_eq!(DisplayMoney::from(Positive::MAX).to_string(), "Unlimited");Tuple Fields§
§0: DecimalTrait Implementations§
Source§impl Clone for DisplayMoney
impl Clone for DisplayMoney
impl Copy for DisplayMoney
Source§impl Debug for DisplayMoney
impl Debug for DisplayMoney
Source§impl Display for DisplayMoney
impl Display for DisplayMoney
impl Eq for DisplayMoney
Source§impl From<Decimal> for DisplayMoney
impl From<Decimal> for DisplayMoney
Source§impl From<Positive> for DisplayMoney
Normalised, so a Positive printed without a precision keeps the
trailing-zero-free rendering of Positive’s own Display.
impl From<Positive> for DisplayMoney
Normalised, so a Positive printed without a precision keeps the
trailing-zero-free rendering of Positive’s own Display.
Source§impl PartialEq for DisplayMoney
impl PartialEq for DisplayMoney
impl StructuralPartialEq for DisplayMoney
Auto Trait Implementations§
impl Freeze for DisplayMoney
impl RefUnwindSafe for DisplayMoney
impl Send for DisplayMoney
impl Sync for DisplayMoney
impl Unpin for DisplayMoney
impl UnsafeUnpin for DisplayMoney
impl UnwindSafe for DisplayMoney
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
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§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.