Crate iso_currency

source ·
Expand description

ISO 4217 currency codes

This crate provides an enum that represents all ISO 4217 currencies and has simple methods to convert between numeric and character code, list of territories where each currency is used, the symbol, and the English name of the currency.

The data for this is taken from https://en.wikipedia.org/wiki/ISO_4217

The Country enum is re-exported from the only dependency - the iso_country crate.

Examples

use iso_currency::{Currency, Country};

assert_eq!(Currency::EUR.name(), "Euro");
assert_eq!(Currency::EUR.numeric(), 978);
assert_eq!(Currency::from_numeric(978), Some(Currency::EUR));
assert_eq!(Currency::from_code("EUR"), Some(Currency::EUR));
assert_eq!(Currency::CHF.used_by(), vec![Country::LI, Country::CH]);
assert_eq!(format!("{}", Currency::EUR.symbol()), "€");
assert_eq!(Currency::EUR.subunit_fraction(), Some(100));
assert_eq!(Currency::JPY.exponent(), Some(0));

Structs

Enums

Traits

  • This trait designates that an Enum can be iterated over. It can be auto generated using strum_macros on your behalf.