Crates.io | iso3166-1 |
lib.rs | iso3166-1 |
version | 1.0.1 |
source | src |
created_at | 2016-01-14 02:00:27.232293 |
updated_at | 2016-02-26 04:11:15.587527 |
description | ISO 3166-1 data. |
homepage | https://github.com/taiyaeix/iso3166-1.rs |
repository | https://github.com/taiyaeix/iso3166-1.rs.git |
max_upload_size | |
id | 3893 |
size | 52,427 |
Rust crate for ISO 3166-1 data.
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
Add the following dependency to your Cargo.toml
:
iso3166_1 = "^1.0"
And include it in your project:
extern crate iso3166_1;
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 info in LICENSE.md. Long story short, ISC.