Struct bill::Currency
[−]
[src]
pub struct Currency { pub symbol: Option<char>, pub value: i64, }
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<char>
Currency symbol
pick any of €
, £
, $
, ¥
etc...
value: i64
value in the smallest possible unit
Methods
impl Currency
[src]
pub fn new() -> Currency
[src]
pub fn from_value(value: i64) -> Currency
[src]
Initialize from i64
pub fn postfix(&self) -> Postfix
[src]
Returns an object that implements Display
for different methods of printing currency.
pub fn prefix(&self) -> Prefix
[src]
Returns an object that implements Display
for different methods of printing currency.
pub fn as_float(&self) -> f64
[src]
Returns the value as float
Warning, do not use this for calculation, this is for displaying only!
pub fn value(&self) -> i64
[src]
Returns the inner value
pub fn symbol(&self) -> Option<char>
[src]
Returns the inner symbol
Methods from Deref<Target = i64>
Trait Implementations
impl Sub<Currency> for Currency
[src]
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.
type Output = Currency
The resulting type after applying the -
operator.
fn sub(self, rhs: Currency) -> Currency
[src]
Performs the -
operation.
impl PartialOrd<Currency> for Currency
[src]
fn partial_cmp(&self, __arg_0: &Currency) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Currency) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Currency) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Currency) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Currency) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Deref for Currency
[src]
Required for DerefMut
type Target = i64
The resulting type after dereferencing.
fn deref(&self) -> &i64
[src]
Dereferences the value.
impl Mul<f64> for Currency
[src]
Multiplies with float, probably not a good idea, help appreciated.
type Output = Currency
The resulting type after applying the *
operator.
fn mul(self, rhs: f64) -> Currency
[src]
Performs the *
operation.
impl Mul<Currency> for i64
[src]
Overloads the '*' operator for i64.
Allows an i64 to be multiplied by a Currency. Completes the commutative property for i64 multiplied by Currency.
type Output = Currency
The resulting type after applying the *
operator.
fn mul(self, rhs: Currency) -> Currency
[src]
Performs the *
operation.
impl Mul<i64> for Currency
[src]
Overloads the '*' operator for Currency objects.
Allows a Currency to be multiplied by an i64.
type Output = Currency
The resulting type after applying the *
operator.
fn mul(self, rhs: i64) -> Currency
[src]
Performs the *
operation.
impl Mul<Currency> for f64
[src]
type Output = Currency
The resulting type after applying the *
operator.
fn mul(self, rhs: Currency) -> Currency
[src]
Performs the *
operation.
impl Copy for Currency
[src]
impl Div<i64> for Currency
[src]
Overloads the '/' operator for Currency objects.
Allows a Currency to be divided by an i64.
type Output = Currency
The resulting type after applying the /
operator.
fn div(self, rhs: i64) -> Currency
[src]
Performs the /
operation.
impl Eq for Currency
[src]
impl PartialEq<Currency> for Currency
[src]
fn eq(&self, __arg_0: &Currency) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Currency) -> bool
[src]
This method tests for !=
.
impl Serialize for Currency
[src]
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl From<i64> for Currency
[src]
impl From<(i64, char)> for Currency
[src]
impl From<(char, i64)> for Currency
[src]
impl Clone for Currency
[src]
fn clone(&self) -> Currency
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Add<Currency> for Currency
[src]
Overloads the '+' operator for Currency objects.
Panics
Panics if the two addends are different types of currency, as denoted by the Currency's symbol.
type Output = Currency
The resulting type after applying the +
operator.
fn add(self, rhs: Currency) -> Currency
[src]
Performs the +
operation.
impl Debug for Currency
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter. Read more