3 releases (stable)

Uses old Rust 2015

1.0.1 Feb 26, 2016
1.0.0 Feb 24, 2016
0.1.0 Jan 14, 2016

#3 in #iso3166

Download history 30/week @ 2021-01-15 44/week @ 2021-01-22 13/week @ 2021-01-29 53/week @ 2021-02-05 42/week @ 2021-02-12 9/week @ 2021-02-19 21/week @ 2021-02-26 19/week @ 2021-03-05 77/week @ 2021-03-12 51/week @ 2021-03-19 144/week @ 2021-03-26 59/week @ 2021-04-02 93/week @ 2021-04-09 94/week @ 2021-04-16 56/week @ 2021-04-23 97/week @ 2021-04-30

230 downloads per month

ISC license

46KB
1.5K SLoC

travis-badge license-badge

iso3166-1.rs

Rust crate for ISO 3166-1 data.

What is ISO 3166-1

ISO 3166-1 is part of the ISO 3166 standard published by the International Organization for Standardization (ISO), and defines codes for the names of countries, dependent territories, and special areas of geographical interest.

-- Wikipedia

Installation

Add the following dependency to your Cargo.toml:

iso3166_1 = "^1.0"

And include it in your project:

extern crate iso3166_1;

Examples

Retrieve all country codes:

extern crate iso3166_1;

fn main() {
    let countries = iso3166_1::all();
}

Retrieve a country code by its alpha2 code:

extern crate iso3166_1;

fn main() {
    let country = iso3166_1::alpha2("AF").unwrap();
}

Retrieve a country code by its alpha3 code:

extern crate iso3166_1;

fn main() {
    let country = iso3166_1::alpha3("ATA").unwrap();
}

Retrieve a country code by its name:

extern crate iso3166_1;

fn main() {
    let country = iso3166_1::name("Angola").unwrap();
}

Retrieve a country code by its numeric number:

extern crate iso3166_1;

fn main() {
    let country = iso3166_1::num("016").unwrap();
}

Retrieve country codes by a range of their numeric numbers:

extern crate iso3166_1;

fn main() {
    // Getting all values between `100` and `300`:
    iso3166_1::num_range(Some("100"), Some("300"));

    // Getting all values from `400` and beyond:
    iso3166_1::num_range(Some("400"), None);

    // Getting all values up to `500`:
    iso3166_1::num_range(None, Some("500"));

    // Getting no values, if that's your thing:
    iso3166_1::num_range(None, None);
}

License

License info in LICENSE.md. Long story short, ISC.

No runtime deps