8 releases

0.4.1 Mar 26, 2021
0.4.0 May 15, 2020
0.3.2 May 13, 2020
0.2.1 May 9, 2020
0.1.0 Oct 13, 2019

#19 in Internationalization (i18n)

Download history 23/week @ 2020-12-29 23/week @ 2021-01-05 26/week @ 2021-01-12 26/week @ 2021-01-19 53/week @ 2021-01-26 30/week @ 2021-02-02 19/week @ 2021-02-09 115/week @ 2021-02-16 50/week @ 2021-02-23 65/week @ 2021-03-02 50/week @ 2021-03-09 43/week @ 2021-03-16 51/week @ 2021-03-23 47/week @ 2021-03-30 58/week @ 2021-04-06 45/week @ 2021-04-13

186 downloads per month
Used in 2 crates (via podcast_search)

MIT license

22KB
354 lines

ISO 4217 currency codes

docs badge build badge crates badge

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.

Features

The crate has only one optional feature - with-serde. If you need serialization/deserialization support using serde you should include the feature in your dependency on iso_currency, for example like this:

iso_currency = { version = "0.4.1", features = ["with-serde"] }

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));

Want to help improve the data?

The Currency enum and its implementations are generated from the isodata.tsv file. It is a table of <tab> separated values. If you wanna correct some value or add some missing values you just need to make a pull request editing that table.

One thing to watch out for is to have always the same amount of fields on a row, even if an optional field is missing. This means on each row you should have 5 tabs.

The used_by_alpha2 column is a bit different. It can be empty but if not it includes a list, separated by a semicolon (without a trailing semicolon), of ISO 3166-1 2-letter country codes in all caps.

Dependencies

~73–265KB