| Crates.io | iso3166-static |
| lib.rs | iso3166-static |
| version | 0.4.1 |
| created_at | 2025-12-21 14:38:44.055346+00 |
| updated_at | 2026-01-15 04:15:30.055463+00 |
| description | Static ISO3166 Data |
| homepage | https://github.com/jcape/iso3166 |
| repository | https://github.com/jcape/iso3166 |
| max_upload_size | |
| id | 1998059 |
| size | 87,506 |
This crate provides generated enumerations for use as with ISO 3166-1 codes. This crate is both no-std and no-alloc (with no need/desire to enable them), and supports serde via the "serde" feature.
There are three primary objects in this crate:
Numeric - Numeric country codes.Alpha2 - Two-character country codes.Alpha3 - Three-character country codes.By default, this crate compiles with serde enabled, and alloc disabled. If your compilation enables the alloc feature on the serde crate, you should enable it here as well to prevent deserialization failures.
default: Enables the serde feature by default.alloc: Enables the use of the alloc crate.serde: Enables implementations of the [serde::Deserialize] and [serde::Serialize] traits.use iso3166_static::{Alpha2, Alpha3, Numeric};
const USA_ALPHA2: &str = "US";
let alpha2 = Alpha2::try_from(USA_ALPHA2).expect("alpha2");
let alpha3 = Alpha3::try_from(alpha2.clone()).expect("alpha3");
let numeric = Numeric::try_from(alpha3.clone()).expect("numeric");
assert_eq!(USA_ALPHA2, alpha2.as_str());
assert_eq!(alpha2, alpha3);
assert_eq!(alpha2, numeric);
assert_eq!(alpha3, numeric);
use core::str::FromStr;
use iso3166_static::{Alpha2, Alpha3, Numeric};
let USA_ALPHA3: &str = "USA";
let numeric = Numeric::UnitedStatesOfAmerica;
let alpha3 = Alpha3::try_from(numeric.clone()).expect("alpha3");
let alpha2 = Alpha2::try_from(numeric.clone()).expect("alpha2");
assert_eq!(alpha3.as_str(), USA_ALPHA3);
assert_eq!(numeric, alpha3);
assert_eq!(numeric, alpha2);
assert_eq!(alpha3, alpha2);