Skip to main content

Money

Struct Money 

Source
pub struct Money { /* private fields */ }

Implementations§

Source§

impl Money

Source

pub fn new(currency: Currency, amount: Decimal) -> Self

Trait Implementations§

Source§

impl Add<Decimal> for Money

Source§

type Output = Money

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Decimal) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Money> for Decimal

Source§

type Output = Money

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Money) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for Money

Money + Money = Money

Source§

type Output = Money

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign for Money

Money += Money

Source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
Source§

impl BaseMoney for Money

Source§

fn currency(&self) -> Currency

Get currency of money

Source§

fn amount(&self) -> Decimal

Get amount of money

Source§

fn round(self) -> Self

Round money using Currency’s rounding strategy to the scale of currency’s minor unit

Source§

fn name(&self) -> &str

Get currency name
Source§

fn symbol(&self) -> &str

Get money symbol
Source§

fn code(&self) -> &str

Get money ISO 4217 code
Source§

fn numeric_code(&self) -> i32

Get currency ISO 4217 numeric code
Source§

fn minor_unit(&self) -> u16

Get money minor unit
Source§

fn minor_amount(&self) -> MoneyResult<i128>

Get money amount in its smallest unit
Source§

fn thousand_separator(&self) -> &'static str

Get money thousands separator
Source§

fn decimal_separator(&self) -> &'static str

Get money decimal separator
Source§

fn is_zero(&self) -> bool

Check if amount is 0
Source§

fn is_positive(&self) -> bool

Check if sign is +
Source§

fn is_negative(&self) -> bool

Check if sign is -
Source§

fn format_code(&self) -> String

Format money with code along with thousands and decimal separators. Example: USD 1,234.45
Source§

fn format_symbol(&self) -> String

Format money with symbol along with thousands and decimal separators. Example: $1,234.45
Source§

fn format_code_minor(&self) -> MoneyResult<String>

Format money with code in the smallest unit along with thousands separators. Example USD 1,234.45 –> USD 123,445 ¢ If the currency has no minor unit symbol, it defaults to “minor”. You can set the minor unit symbol in Currency type’s setter.
Source§

fn format_symbol_minor(&self) -> MoneyResult<String>

Format money with code in the smallest unit along with thousands separators. Example $1,234.45 –> $123,445 ¢ If the currency has no minor unit symbol, it defaults to “minor”. You can set the minor unit symbol in Currency type’s setter.
Source§

fn display(&self) -> String

Default display of money
Source§

fn countries(&self) -> Option<Vec<Country>>

Get countries using this currency
Source§

impl BaseOps for Money

Source§

fn clamp(&self, from: Decimal, to: Decimal) -> Self

clamp the money amount between from and to inclusively.

Source§

fn abs(&self) -> Self

make money positive
Source§

fn min(&self, rhs: Self) -> Self

Source§

fn max(&self, rhs: Self) -> Self

Source§

fn add(&self, rhs: Decimal) -> MoneyResult<Self>

Source§

fn sub(&self, rhs: Decimal) -> MoneyResult<Self>

Source§

fn mul(&self, rhs: Decimal) -> MoneyResult<Self>

Source§

fn div(&self, rhs: Decimal) -> MoneyResult<Self>

Source§

impl Clone for Money

Source§

fn clone(&self) -> Money

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CustomMoney for Money

Source§

fn set_thousand_separator(&mut self, separator: &'static str)

Source§

fn set_decimal_separator(&mut self, separator: &'static str)

Source§

fn round_with(self, decimal_points: u32, strategy: RoundingStrategy) -> Self

Source§

impl Debug for Money

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Money

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Div<Decimal> for Money

Source§

type Output = Money

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Decimal) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Money> for Decimal

Source§

type Output = Money

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Money) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for Money

Money / Money = Money

Source§

type Output = Money

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl DivAssign for Money

Money /= Money

Source§

fn div_assign(&mut self, other: Self)

Performs the /= operation. Read more
Source§

impl FromStr for Money

Source§

type Err = MoneyError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Mul<Decimal> for Money

Source§

type Output = Money

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Decimal) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Money> for Decimal

Source§

type Output = Money

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Money) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for Money

Money * Money = Money

Source§

type Output = Money

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign for Money

Money *= Money

Source§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
Source§

impl Neg for Money

Source§

type Output = Money

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl PartialEq for Money

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Money

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub<Decimal> for Money

Source§

type Output = Money

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Decimal) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Money> for Decimal

Source§

type Output = Money

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Money) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for Money

Money - Money = Money

Source§

type Output = Money

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign for Money

Money -= Money

Source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
Source§

impl Copy for Money

Source§

impl Eq 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 UnwindSafe for Money

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.