codes_iso_4217/
lib.rs

1/*!
2This package contains an implementation of the
3[ISO 4217](https://www.iso.org/iso-4217-currency-codes.html)
4Currency Codes specification.
5
6This standard establishes internationally recognized codes for the
7representation of currencies that enable clarity and reduce errors. Currencies
8are represented both numerically and alphabetically, using either three digits
9or three letters. Some of the alphabetic codes for major currencies are
10familiar, such as "EUR" for Euros. Fortunately, ISO 4217 covers everything
11from Afghanis to Zambian Kwacha as well.
12
13This package extends the data model of the ISO specification by adding a
14currency symbol string (and Unicode code points for the symbol) where possible
15to all symbols.
16
17# Example
18
19```rust
20use codes_iso_4217::{CurrencyCode, ISO_4217};
21
22let code = CurrencyCode::BZD;
23
24assert_eq!(code.alpha_code(), "BZD");
25assert_eq!(code.numeric_code(), Some(84));
26
27// feature = "currency_name"
28// assert_eq!(code.currency_name(), "Belize Dollar");
29
30// feature = "country_name"
31// assert_eq!(code.country_name(), "BELIZE");
32
33// feature = "monetary_units"
34// assert_eq!(code.monetary_units(), 2);
35
36// feature = "is_fund"
37// assert_eq!(code.is_fund(), false);
38
39// feature = "historical_codes"
40// assert_eq!(code.is_historical(), false);
41// assert_eq!(code.withdrawal_date(), None);
42
43// feature = "symbols"
44// assert_eq!(code.currency_symbol_str(), Some("BZ$"));
45// assert_eq!(code.currency_symbol_code_points(), Some(&[0x42, 0x5a, 0x24]));
46
47assert_eq!(ISO_4217.title(), "Currency codes");
48```
49
50# Features
51
52By default only the `serde` feature is enabled, the [CurrencyCode::alpha_code] and
53[CurrencyCode::numeric_code] methods cannot be excluded.
54
55* `serde` - Enables serialization of the [CurrencyCode] type.
56* `currency_name` - Adds the [CurrencyCode::currency_name] method.
57* `country_name` - Adds the [CurrencyCode::country_name] method.
58* `monetary_units` - Adds the [CurrencyCode::monetary_units] method.
59* `is_fund` - Adds the [CurrencyCode::is_fund] method.
60* `historical_codes` - Adds the [CurrencyCode::is_historical] and [CurrencyCode::withdrawal_date] methods.
61* `symbols` - Adds the [CurrencyCode::currency_symbol_str] and [CurrencyCode::currency_symbol_code_points] methods.
62
63*/
64
65#![warn(
66    unknown_lints,
67    // ---------- Stylistic
68    absolute_paths_not_starting_with_crate,
69    elided_lifetimes_in_paths,
70    explicit_outlives_requirements,
71    macro_use_extern_crate,
72    nonstandard_style, /* group */
73    noop_method_call,
74    rust_2018_idioms,
75    single_use_lifetimes,
76    trivial_casts,
77    trivial_numeric_casts,
78    // ---------- Future
79    future_incompatible, /* group */
80    rust_2021_compatibility, /* group */
81    // ---------- Public
82    missing_debug_implementations,
83    // missing_docs,
84    unreachable_pub,
85    // ---------- Unsafe
86    unsafe_code,
87    unsafe_op_in_unsafe_fn,
88    // ---------- Unused
89    unused, /* group */
90)]
91#![deny(
92    // ---------- Public
93    exported_private_dependencies,
94    private_in_public,
95    // ---------- Deprecated
96    anonymous_parameters,
97    bare_trait_objects,
98    ellipsis_inclusive_range_patterns,
99    // ---------- Unsafe
100    deref_nullptr,
101    drop_bounds,
102    dyn_drop,
103)]
104
105// ------------------------------------------------------------------------------------------------
106//
107// The rest of this file is generated by the package build script.
108//
109// ------------------------------------------------------------------------------------------------
110
111include!(concat!(env!("OUT_DIR"), "/generated.rs"));