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"
Currency symbol
pick any of β¬
, Β£
, $
, Β₯
etc...
value in the smallest possible unit
Creates a blank Currency as Currency(None, 0)
let mut c = Currency::new();
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 value as float
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
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.
Performs copy-assignment from source
. Read more
Returns the "default value" for a type. Read more
Overloads the '+' operator for Currency objects.
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.
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Overloads the '-' operator for Currency objects.
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.
Serialize this value into the given Serde serializer. Read more
Formats the value using the given formatter. 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.
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.
Multiplies with float, probably not a good idea, help appreciated.
The resulting type after applying the *
operator.
Performs the *
operation.
The resulting type after dereferencing.
converts from a tuple of symbol
and i64
converts from a tuple of i64
and symbol
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
π¬ This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
π¬ This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
π¬ This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
π¬ This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
π¬ This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more