[−][src]Struct rusty_money::Money
Represents an amount of a given currency.
Money represents financial amounts through a Decimal (owned) and a Currency (refernce).
Operations on Money objects always create new instances of Money, with the exception
of round()
.
Methods
impl Money
[src]
pub fn new(amount: i64, currency: &'static Currency) -> Money
[src]
Creates a Money object given an integer and a currency reference.
The integer represents minor units of the currency (e.g. 1000 -> 10.00 in USD )
pub fn from_minor(amount: i64, currency: &'static Currency) -> Money
[src]
Creates a Money object given an integer and a currency reference.
The integer represents minor units of the currency (e.g. 1000 -> 10.00 in USD )
pub fn from_major(amount: i64, currency: &'static Currency) -> Money
[src]
Creates a Money object given an integer and a currency reference.
The integer represents major units of the currency (e.g. 1000 -> 1,000 in USD )
pub fn from_decimal(amount: Decimal, currency: &'static Currency) -> Money
[src]
Creates a Money object given a decimal amount and a currency reference.
pub fn from_str(amount: &str, currency: &str) -> Result<Money, MoneyError>
[src]
Creates a Money object given an amount str and a currency str.
Supports fuzzy amount strings like "100", "100.00" and "-100.00"
pub fn from_string(
amount: String,
currency: String
) -> Result<Money, MoneyError>
[src]
amount: String,
currency: String
) -> Result<Money, MoneyError>
Creates a Money object given an amount string and a currency string.
Supports fuzzy amount strings like "100", "100.00" and "-100.00"
pub fn amount(&self) -> &Decimal
[src]
Returns a reference to the Decimal amount.
pub fn currency(&self) -> &'static Currency
[src]
Returns the Currency type.
pub fn is_zero(&self) -> bool
[src]
Returns true if amount == 0.
pub fn is_positive(&self) -> bool
[src]
Returns true if amount > 0.
pub fn is_negative(&self) -> bool
[src]
Returns true if amount < 0.
pub fn allocate_to(&self, number: i32) -> Result<Vec<Money>, MoneyError>
[src]
Divides money equally into n shares.
If the divison cannot be applied perfectly, it allocates the remainder to some of the shares.
pub fn allocate(&self, ratios: Vec<i32>) -> Result<Vec<Money>, MoneyError>
[src]
Divides money into n shares according to a particular ratio.
If the divison cannot be applied perfectly, it allocates the remainder to some of the shares.
pub fn round(&self, digits: u32, strategy: Round) -> Money
[src]
Returns a Money
rounded to the specified number of minor units using the rounding strategy.
Trait Implementations
impl Add<Money> for Money
[src]
type Output = Money
The resulting type after applying the +
operator.
fn add(self, other: Money) -> Money
[src]
impl AddAssign<Money> for Money
[src]
fn add_assign(&mut self, other: Self)
[src]
impl Clone for Money
[src]
impl Debug for Money
[src]
impl Display for Money
[src]
impl Div<Money> for isize
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: Money) -> Money
[src]
impl Div<Money> for i8
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: Money) -> Money
[src]
impl Div<Money> for i16
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: Money) -> Money
[src]
impl Div<Money> for i32
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: Money) -> Money
[src]
impl Div<Money> for i64
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: Money) -> Money
[src]
impl Div<Money> for usize
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: Money) -> Money
[src]
impl Div<Money> for u8
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: Money) -> Money
[src]
impl Div<Money> for u16
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: Money) -> Money
[src]
impl Div<Money> for u32
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: Money) -> Money
[src]
impl Div<Money> for u64
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: Money) -> Money
[src]
impl Div<i16> for Money
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: i16) -> Money
[src]
impl Div<i32> for Money
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: i32) -> Money
[src]
impl Div<i64> for Money
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: i64) -> Money
[src]
impl Div<i8> for Money
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: i8) -> Money
[src]
impl Div<isize> for Money
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: isize) -> Money
[src]
impl Div<u16> for Money
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: u16) -> Money
[src]
impl Div<u32> for Money
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: u32) -> Money
[src]
impl Div<u64> for Money
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: u64) -> Money
[src]
impl Div<u8> for Money
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: u8) -> Money
[src]
impl Div<usize> for Money
[src]
type Output = Money
The resulting type after applying the /
operator.
fn div(self, rhs: usize) -> Money
[src]
impl DivAssign<i16> for Money
[src]
fn div_assign(&mut self, rhs: i16)
[src]
impl DivAssign<i32> for Money
[src]
fn div_assign(&mut self, rhs: i32)
[src]
impl DivAssign<i64> for Money
[src]
fn div_assign(&mut self, rhs: i64)
[src]
impl DivAssign<i8> for Money
[src]
fn div_assign(&mut self, rhs: i8)
[src]
impl DivAssign<isize> for Money
[src]
fn div_assign(&mut self, rhs: isize)
[src]
impl DivAssign<u16> for Money
[src]
fn div_assign(&mut self, rhs: u16)
[src]
impl DivAssign<u32> for Money
[src]
fn div_assign(&mut self, rhs: u32)
[src]
impl DivAssign<u64> for Money
[src]
fn div_assign(&mut self, rhs: u64)
[src]
impl DivAssign<u8> for Money
[src]
fn div_assign(&mut self, rhs: u8)
[src]
impl DivAssign<usize> for Money
[src]
fn div_assign(&mut self, rhs: usize)
[src]
impl Eq for Money
[src]
impl Mul<Money> for isize
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: Money) -> Money
[src]
impl Mul<Money> for i8
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: Money) -> Money
[src]
impl Mul<Money> for i16
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: Money) -> Money
[src]
impl Mul<Money> for i32
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: Money) -> Money
[src]
impl Mul<Money> for i64
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: Money) -> Money
[src]
impl Mul<Money> for usize
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: Money) -> Money
[src]
impl Mul<Money> for u8
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: Money) -> Money
[src]
impl Mul<Money> for u16
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: Money) -> Money
[src]
impl Mul<Money> for u32
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: Money) -> Money
[src]
impl Mul<Money> for u64
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: Money) -> Money
[src]
impl Mul<i16> for Money
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: i16) -> Money
[src]
impl Mul<i32> for Money
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: i32) -> Money
[src]
impl Mul<i64> for Money
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: i64) -> Money
[src]
impl Mul<i8> for Money
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: i8) -> Money
[src]
impl Mul<isize> for Money
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: isize) -> Money
[src]
impl Mul<u16> for Money
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: u16) -> Money
[src]
impl Mul<u32> for Money
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: u32) -> Money
[src]
impl Mul<u64> for Money
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: u64) -> Money
[src]
impl Mul<u8> for Money
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: u8) -> Money
[src]
impl Mul<usize> for Money
[src]
type Output = Money
The resulting type after applying the *
operator.
fn mul(self, rhs: usize) -> Money
[src]
impl MulAssign<i16> for Money
[src]
fn mul_assign(&mut self, rhs: i16)
[src]
impl MulAssign<i32> for Money
[src]
fn mul_assign(&mut self, rhs: i32)
[src]
impl MulAssign<i64> for Money
[src]
fn mul_assign(&mut self, rhs: i64)
[src]
impl MulAssign<i8> for Money
[src]
fn mul_assign(&mut self, rhs: i8)
[src]
impl MulAssign<isize> for Money
[src]
fn mul_assign(&mut self, rhs: isize)
[src]
impl MulAssign<u16> for Money
[src]
fn mul_assign(&mut self, rhs: u16)
[src]
impl MulAssign<u32> for Money
[src]
fn mul_assign(&mut self, rhs: u32)
[src]
impl MulAssign<u64> for Money
[src]
fn mul_assign(&mut self, rhs: u64)
[src]
impl MulAssign<u8> for Money
[src]
fn mul_assign(&mut self, rhs: u8)
[src]
impl MulAssign<usize> for Money
[src]
fn mul_assign(&mut self, rhs: usize)
[src]
impl Ord for Money
[src]
fn cmp(&self, other: &Money) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Money> for Money
[src]
impl PartialOrd<Money> for Money
[src]
fn partial_cmp(&self, other: &Money) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for Money
[src]
impl StructuralPartialEq for Money
[src]
impl Sub<Money> for Money
[src]
type Output = Money
The resulting type after applying the -
operator.
fn sub(self, other: Money) -> Money
[src]
impl SubAssign<Money> for Money
[src]
fn sub_assign(&mut self, other: Self)
[src]
Auto Trait Implementations
impl RefUnwindSafe for Money
impl Send for Money
impl Sync for Money
impl Unpin for Money
impl UnwindSafe for Money
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,