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::from_country(Country::IO), vec![Currency::GBP, Currency::USD]);
assert_eq!(Currency::from(Country::AF), Currency::AFN);
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));
assert_eq!(Currency::BOV.is_fund(), true);
assert_eq!(Currency::XDR.is_special(), true);
assert_eq!(Currency::VES.is_superseded(), Some(Currency::VED));
assert_eq!(Currency::VED.is_superseded(), None);
assert_eq!(Currency::VES.latest(), Currency::VED);
assert_eq!(Currency::BOV.flags(), vec![iso_currency::Flag::Fund]);
Structs§
- Currency
Iter - An iterator over the variants of Currency
- Currency
Symbol - Parse
Currency Error
Enums§
Traits§
- Into
Enum Iterator iterator
- This trait designates that an
Enum
can be iterated over. It can be auto generated using theEnumIter
derive macro.