iso3166-static

Crates.ioiso3166-static
lib.rsiso3166-static
version0.4.1
created_at2025-12-21 14:38:44.055346+00
updated_at2026-01-15 04:15:30.055463+00
descriptionStatic ISO3166 Data
homepagehttps://github.com/jcape/iso3166
repositoryhttps://github.com/jcape/iso3166
max_upload_size
id1998059
size87,506
James Cape (jcape)

documentation

README

ISO 3166 Static Data

CratesDocsMSRV 1.88.0

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.

Features

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.

Examples

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);
Commit count: 74

cargo fmt