Module iso::country

source ·
Expand description

Type definitions related to the ISO 3166-1 country code standard

Most of this module is dedicated to the code enumerations, which each enumerate over their corresponding iso country code sets. Each can be converted into each other.

Basic usage

// the variant representing the united states
let united_states = Iso3166_1_alpha_2::Us;

println!(
    "The name of the country represented by the ISO 3166-1 alpha-3 code of {} is {}!",
    TryInto::<Iso3166_1_alpha_3>::try_into(united_states).unwrap().code(),
    united_states.name()
);

assert_eq!(united_states.name(), "United States of America");
assert_eq!(united_states.code(), "US");
assert_eq!(united_states.try_into(), Ok(Iso3166_1_alpha_2::Us));
assert_eq!(united_states.try_into(), Ok(Iso3166_1_alpha_3::Usa));

Enums

  • A list of all possible errors encountered while working with the country code enumerations
  • Enumeration over all possible ISO 3166-1 alpha-2 country codes
  • Enumeration over all possible ISO 3166-1 alpha-3 country codes

Traits

  • An abstraction over a country code providing ways to extract information as well as convert