pub struct Currency {
pub symbol: Option<Symbol>,
pub value: i64,
}Expand description
Represents currency through an optional symbol and amount of coin.
Each 100 coins results in a banknote. (100 is formatted as 1.00)
The currency will be formatted as such: Currency(Some('$'), 432) ==> “$4.32”
Fields§
§symbol: Option<Symbol>Currency symbol
pick any of €, £, $, ¥ etc…
value: i64value in the smallest possible unit
Implementations§
Source§impl Currency
impl Currency
Sourcepub fn from_value(value: i64) -> Currency
pub fn from_value(value: i64) -> Currency
Initialize from i64
Sourcepub fn postfix(&self) -> Postfix<'_>
pub fn postfix(&self) -> Postfix<'_>
Returns an object that implements Display for different methods of printing currency.
Examples found in repository?
More examples
Sourcepub fn prefix(&self) -> Prefix<'_>
pub fn prefix(&self) -> Prefix<'_>
Returns an object that implements Display for different methods of printing currency.
Examples found in repository?
More examples
Trait Implementations§
Source§impl Add for Currency
Overloads the ‘+’ operator for Currency objects.
impl Add for Currency
Overloads the ‘+’ operator for Currency objects.
§Panics
Panics if the two addends are different types of currency, as denoted by the Currency’s symbol.
Source§impl Div<i64> for Currency
Overloads the ‘/’ operator for Currency objects.
impl Div<i64> for Currency
Overloads the ‘/’ operator for Currency objects.
Allows a Currency to be divided by an i64.
Source§impl Mul<Currency> for i64
Overloads the ‘*’ operator for i64.
impl Mul<Currency> for i64
Overloads the ‘*’ operator for i64.
Allows an i64 to be multiplied by a Currency. Completes the commutative property for i64 multiplied by Currency.
Source§impl Mul<i64> for Currency
Overloads the ‘*’ operator for Currency objects.
impl Mul<i64> for Currency
Overloads the ‘*’ operator for Currency objects.
Allows a Currency to be multiplied by an i64.
Source§impl PartialOrd for Currency
impl PartialOrd for Currency
Source§impl Sub for Currency
Overloads the ‘-’ operator for Currency objects.
impl Sub for Currency
Overloads the ‘-’ operator for Currency objects.
§Panics
Panics if the minuend and subtrahend are two different types of currency, as denoted by the Currency’s symbol.