macro_rules! define_currency {
    (
        $currency_name:ident,
        $base_type:ty,
        $base:expr,
        $symbol:expr,
        $proper_name:expr,
        $style:ident,
        $is_iso:expr,
        $is_crypto:expr
    ) => { ... };
}
Expand description

Shorthand for defining a new Currency. All ISO-4217 currencies already have an entry.

Example:

define_currency!(USD, u64, 1_00, "$", "United States Dollar", PrefixAttached, true, false);

where:

  • the first argument should be an ident specifying the (programmatic and short-hand) name of the currency
  • the second argument specifies the “backing” type used to store Amounts of this Currency.
  • the third argument should be an expression resolving to a number that specifies the underlying base of this Currency. Typically this is a 1 followed by a number of zeroes exactly corresponding with the number of digits this Currency will support after the decimal point.
  • the fourth argument should be a string literal such as “$” or “ETH” specifying the symbol that will be used when working with Amounts of this Currency.
  • the fifth argument should be a string literal containing a verbose/proper name for this Currency such as “United States Dollar”.
  • the sixth argument should be a variant name from FormatStyle, minus the leading FormatStyle:: portion, as that is implied, and determines how Amounts of this Currency should be displayed.
  • the seventh argument should be a boolean expression specifying whether or not this Currency is part of ISO-4217.
  • the eighth and final argument should be a boolean expression specifying whether or not this Currency is a cryptocurrency.