Skip to main content

Crate use_currency_code

Crate use_currency_code 

Source
Expand description

§use-currency-code

Small ISO 4217-style currency code primitives for RustUse.

§Example

use use_currency_code::{is_currency_code, parse_currency_code};

let currency = parse_currency_code("usd").unwrap();

assert_eq!(currency.as_str(), "USD");
assert!(is_currency_code("EUR"));

§Scope

  • Validate 3-letter alphabetic currency code shapes.
  • Normalize currency code identifiers to uppercase.
  • Provide a small CurrencyCode newtype for validated currency identifiers.

§Non-goals

  • Exchange rates.
  • Money arithmetic.
  • Decimal formatting.
  • Live currency metadata downloads.
  • Finance APIs.

§License

Licensed under either of the following, at your option:

  • Apache License, Version 2.0
  • MIT license

Structs§

CurrencyCode
A normalized 3-letter currency code identifier.

Constants§

COMMON_CURRENCY_CODES
Common currency code examples used in docs and tests.

Functions§

is_currency_code
Returns true when the input is a 3-letter currency code identifier.
normalize_currency_code
Normalizes a 3-letter currency code identifier to uppercase.
parse_currency_code
Parses a currency code identifier and normalizes it to uppercase.