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

Currency symbol

pick any of €, £, $, ¥ etc...

value in the smallest possible unit

Methods

impl Currency
[src]

[src]

Creates a blank Currency as Currency(None, 0)

Examples

let mut c = Currency::new();

[src]

Initialize from i64

[src]

Returns an object that implements Display for different methods of printing currency.

[src]

Returns an object that implements Display for different methods of printing currency.

[src]

[src]

Returns the inner value

[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.

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl PartialOrd<Currency> for Currency
[src]

[src]

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

[src]

This method tests less than (for self and other) and is used by the < operator. Read more

[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

[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

The resulting type after dereferencing.

[src]

Dereferences the value.

impl Mul<f64> for Currency
[src]

Multiplies with float, probably not a good idea, help appreciated.

The resulting type after applying the * operator.

[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.

The resulting type after applying the * operator.

[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.

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl Mul<Currency> for f64
[src]

The resulting type after applying the * operator.

[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.

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl Eq for Currency
[src]

impl PartialEq<Currency> for Currency
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Serialize for Currency
[src]

[src]

Serialize this value into the given Serde serializer. Read more

impl From<i64> for Currency
[src]

[src]

converts from a i64

impl From<(i64, char)> for Currency
[src]

[src]

converts from a tuple of i64 and symbol

impl From<(char, i64)> for Currency
[src]

[src]

converts from a tuple of symbol and i64

impl Clone for Currency
[src]

[src]

Returns a copy of the value. Read more

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.

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl Debug for Currency
[src]

[src]

Formats the value using the given formatter. Read more

impl Default for Currency
[src]

[src]

Returns the "default value" for a type. Read more

Auto Trait Implementations

impl Send for Currency

impl Sync for Currency