11 releases

0.4.4 Aug 26, 2023
0.4.3 Jun 7, 2022
0.4.2 Aug 9, 2021
0.4.1 Mar 26, 2021
0.2.0 Oct 13, 2019

#2 in Finance

Download history 5711/week @ 2024-01-30 5578/week @ 2024-02-06 4264/week @ 2024-02-13 4371/week @ 2024-02-20 5228/week @ 2024-02-27 7107/week @ 2024-03-05 6958/week @ 2024-03-12 6525/week @ 2024-03-19 5222/week @ 2024-03-26 6801/week @ 2024-04-02 5999/week @ 2024-04-09 6435/week @ 2024-04-16 5650/week @ 2024-04-23 5006/week @ 2024-04-30 5124/week @ 2024-05-07 3949/week @ 2024-05-14

20,857 downloads per month
Used in 17 crates (15 directly)

MIT license

592 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.


The crate has only two optional features:

  • with-serde
  • iterator


If you need serialization/deserialization support using serde you should include the feature in your dependency on iso_currency.

This would derive serde's Serialize and Deserialize on Currency.


If you specify the iterator feature on iso_currency, it will derive strum's EnumIter trait on Currency, which provides an iterator over all variants of it. Here's an example usage:

use iso_currency::IntoEnumIterator;
let mut iter = Currency::iter();


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

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 6 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.