Skip to main content

Currency

Trait Currency 

Source
pub trait Currency {
    // Required methods
    fn code(&self) -> &'static str;
    fn minor_units(&self) -> u32;
    fn numeric_code(&self) -> u32;
}
Expand description

Common trait for all currencies.

Required Methods§

Source

fn code(&self) -> &'static str

Returns the unique ISO alphabetic code for this currency (e.g., “USD” or “JPY”).

Source

fn minor_units(&self) -> u32

Returns the number of minor units supported by the currency. Currencies like USD and EUR currently support 2, but others like JPY or KRW support zero.

Source

fn numeric_code(&self) -> u32

Returns the unique ISO numeric code for this currency.

Trait Implementations§

Source§

impl Debug for &dyn Currency

Debug output for a dynamically-typed Currency. Only prints the code since that is unique.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl MinorUnits for &dyn Currency

Blanket implementation of MinorUnits for an &dyn Currency.

Source§

impl PartialEq for &dyn Currency

Allows comparing dynamically-typed Currency instances. They are equal of their code() methods return the same value.

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Implementors§

Source§

impl Currency for AED

Source§

impl Currency for AFN

Source§

impl Currency for ALL

Source§

impl Currency for AMD

Source§

impl Currency for AOA

Source§

impl Currency for ARS

Source§

impl Currency for AUD

Source§

impl Currency for AWG

Source§

impl Currency for AZN

Source§

impl Currency for BAM

Source§

impl Currency for BBD

Source§

impl Currency for BDT

Source§

impl Currency for BHD

Source§

impl Currency for BIF

Source§

impl Currency for BMD

Source§

impl Currency for BND

Source§

impl Currency for BOB

Source§

impl Currency for BOV

Source§

impl Currency for BRL

Source§

impl Currency for BSD

Source§

impl Currency for BTN

Source§

impl Currency for BWP

Source§

impl Currency for BYN

Source§

impl Currency for BZD

Source§

impl Currency for CAD

Source§

impl Currency for CDF

Source§

impl Currency for CHE

Source§

impl Currency for CHF

Source§

impl Currency for CHW

Source§

impl Currency for CLF

Source§

impl Currency for CLP

Source§

impl Currency for CNY

Source§

impl Currency for COP

Source§

impl Currency for COU

Source§

impl Currency for CRC

Source§

impl Currency for CUP

Source§

impl Currency for CVE

Source§

impl Currency for CZK

Source§

impl Currency for DJF

Source§

impl Currency for DKK

Source§

impl Currency for DOP

Source§

impl Currency for DZD

Source§

impl Currency for EGP

Source§

impl Currency for ERN

Source§

impl Currency for ETB

Source§

impl Currency for EUR

Source§

impl Currency for FJD

Source§

impl Currency for FKP

Source§

impl Currency for GBP

Source§

impl Currency for GEL

Source§

impl Currency for GHS

Source§

impl Currency for GIP

Source§

impl Currency for GMD

Source§

impl Currency for GNF

Source§

impl Currency for GTQ

Source§

impl Currency for GYD

Source§

impl Currency for HKD

Source§

impl Currency for HNL

Source§

impl Currency for HTG

Source§

impl Currency for HUF

Source§

impl Currency for IDR

Source§

impl Currency for ILS

Source§

impl Currency for INR

Source§

impl Currency for IQD

Source§

impl Currency for IRR

Source§

impl Currency for ISK

Source§

impl Currency for JMD

Source§

impl Currency for JOD

Source§

impl Currency for JPY

Source§

impl Currency for KES

Source§

impl Currency for KGS

Source§

impl Currency for KHR

Source§

impl Currency for KMF

Source§

impl Currency for KPW

Source§

impl Currency for KRW

Source§

impl Currency for KWD

Source§

impl Currency for KYD

Source§

impl Currency for KZT

Source§

impl Currency for LAK

Source§

impl Currency for LBP

Source§

impl Currency for LKR

Source§

impl Currency for LRD

Source§

impl Currency for LSL

Source§

impl Currency for LYD

Source§

impl Currency for MAD

Source§

impl Currency for MDL

Source§

impl Currency for MGA

Source§

impl Currency for MKD

Source§

impl Currency for MMK

Source§

impl Currency for MNT

Source§

impl Currency for MOP

Source§

impl Currency for MRU

Source§

impl Currency for MUR

Source§

impl Currency for MVR

Source§

impl Currency for MWK

Source§

impl Currency for MXN

Source§

impl Currency for MXV

Source§

impl Currency for MYR

Source§

impl Currency for MZN

Source§

impl Currency for NAD

Source§

impl Currency for NGN

Source§

impl Currency for NIO

Source§

impl Currency for NOK

Source§

impl Currency for NPR

Source§

impl Currency for NZD

Source§

impl Currency for OMR

Source§

impl Currency for PAB

Source§

impl Currency for PEN

Source§

impl Currency for PGK

Source§

impl Currency for PHP

Source§

impl Currency for PKR

Source§

impl Currency for PLN

Source§

impl Currency for PYG

Source§

impl Currency for QAR

Source§

impl Currency for RON

Source§

impl Currency for RSD

Source§

impl Currency for RUB

Source§

impl Currency for RWF

Source§

impl Currency for SAR

Source§

impl Currency for SBD

Source§

impl Currency for SCR

Source§

impl Currency for SDG

Source§

impl Currency for SEK

Source§

impl Currency for SGD

Source§

impl Currency for SHP

Source§

impl Currency for SLE

Source§

impl Currency for SOS

Source§

impl Currency for SRD

Source§

impl Currency for SSP

Source§

impl Currency for STN

Source§

impl Currency for SVC

Source§

impl Currency for SYP

Source§

impl Currency for SZL

Source§

impl Currency for THB

Source§

impl Currency for TJS

Source§

impl Currency for TMT

Source§

impl Currency for TND

Source§

impl Currency for TOP

Source§

impl Currency for TRY

Source§

impl Currency for TTD

Source§

impl Currency for TWD

Source§

impl Currency for TZS

Source§

impl Currency for UAH

Source§

impl Currency for UGX

Source§

impl Currency for USD

Source§

impl Currency for USN

Source§

impl Currency for UYI

Source§

impl Currency for UYU

Source§

impl Currency for UYW

Source§

impl Currency for UZS

Source§

impl Currency for VED

Source§

impl Currency for VES

Source§

impl Currency for VND

Source§

impl Currency for VUV

Source§

impl Currency for WST

Source§

impl Currency for XAD

Source§

impl Currency for XAF

Source§

impl Currency for XAG

Source§

impl Currency for XAU

Source§

impl Currency for XBA

Source§

impl Currency for XBB

Source§

impl Currency for XBC

Source§

impl Currency for XBD

Source§

impl Currency for XCD

Source§

impl Currency for XCG

Source§

impl Currency for XDR

Source§

impl Currency for XOF

Source§

impl Currency for XPD

Source§

impl Currency for XPF

Source§

impl Currency for XPT

Source§

impl Currency for XSU

Source§

impl Currency for XTS

Source§

impl Currency for XUA

Source§

impl Currency for XXX

Source§

impl Currency for YER

Source§

impl Currency for ZAR

Source§

impl Currency for ZMW

Source§

impl Currency for ZWG