[][src]Struct bill::Currency

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]

Creates a blank Currency as Currency(None, 0)

Examples

let mut c = Currency::new();

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]

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 PartialOrd<Currency> for Currency
[src]

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.

impl Clone for Currency
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Default for Currency
[src]

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.

impl Eq for Currency
[src]

impl PartialEq<Currency> for Currency
[src]

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.

impl Serialize for Currency
[src]

impl Debug for Currency
[src]

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.

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.

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.

impl Deref for Currency
[src]

Required for DerefMut

type Target = i64

The resulting type after dereferencing.

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

fn from(tpl: (char, i64)) -> Currency
[src]

converts from a tuple of symbol and i64

impl From<i64> for Currency
[src]

fn from(value: i64) -> Currency
[src]

converts from a i64

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

fn from(tpl: (i64, char)) -> Currency
[src]

converts from a tuple of i64 and symbol

Auto Trait Implementations

impl Send for Currency

impl Sync for Currency

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

πŸ”¬ This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

πŸ”¬ This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]