Struct bill::Currency[][src]

pub struct Currency {
    pub symbol: Option<char>,
    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<char>

Currency symbol

pick any of , £, $, ¥ etc…

value: i64

value in the smallest possible unit

Implementations

Creates a blank Currency as Currency(None, 0)

Examples
let mut c = Currency::new();

Initialize from i64

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

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

Returns the inner value

Returns the inner symbol

Methods from Deref<Target = i64>

Trait Implementations

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.

Performs the + operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Required for DerefMut

The resulting type after dereferencing.

Dereferences the value.

Overloads the ‘/’ operator for Currency objects.

Allows a Currency to be divided by an i64.

The resulting type after applying the / operator.

Performs the / operation. Read more

converts from a tuple of symbol and i64

converts from a tuple of i64 and symbol

converts from a i64

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.

Performs the * operation. Read more

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

The resulting type after applying the * operator.

Performs the * operation. Read more

Overloads the ‘*’ operator for Currency objects.

Allows a Currency to be multiplied by an i64.

The resulting type after applying the * operator.

Performs the * operation. Read more

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

This method tests for !=.

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

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

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

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

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

Serialize this value into the given Serde serializer. Read more

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.

Performs the - operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.