pub struct CountryCode {
    pub name: &'static str,
    pub alpha2: &'static str,
    pub alpha3: &'static str,
    pub numeric: i32,
}
Expand description

Sample code

let country = rust_iso3166::from_alpha2("AU");
assert_eq!("AUS", country.unwrap().alpha3);
let country = rust_iso3166::from_alpha3("AUS");
assert_eq!("AU", country.unwrap().alpha2);  
let country = rust_iso3166::from_numeric(036);
assert_eq!("AUS", country.unwrap().alpha3);   
let country = rust_iso3166::from_numeric_str("036");
assert_eq!("AUS", country.unwrap().alpha3);

println!("{:?}", country);   
println!("{:?}", rust_iso3166::ALL);
println!("{:?}", rust_iso3166::ALL_ALPHA2);   
println!("{:?}", rust_iso3166::ALL_ALPHA3);   
println!("{:?}", rust_iso3166::ALL_NAME);   
println!("{:?}", rust_iso3166::ALL_NUMERIC);   
println!("{:?}", rust_iso3166::ALL_NUMERIC_STR);   
println!("{:?}", rust_iso3166::NUMERIC_MAP);  
println!("{:?}", rust_iso3166::ALPHA3_MAP);  
println!("{:?}", rust_iso3166::ALPHA2_MAP);  

Data for each Country Code defined by ISO 3166-1

Fields

name: &'static str

English short name

alpha2: &'static str

Alpha-2 code

alpha3: &'static str

Alpha-3 code

numeric: i32

Numeric code

Implementations

Return len 3 String for CountryCode numeric

Return Subdivision for ISO 3166-2

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.