Crates.io | countries-tools |
lib.rs | countries-tools |
version | 0.2.0 |
source | src |
created_at | 2023-08-05 17:42:21.071156 |
updated_at | 2023-08-07 22:23:34.792316 |
description | ISO 3166 country codes and names optimized, no-std, no-alloc and without unsafe |
homepage | |
repository | https://github.com/jhg/countries-tools-rs |
max_upload_size | |
id | 936640 |
size | 35,413 |
Countries list from ISO 3166-1
After cargo install countries-tools
:
use countries_tools::{Country, CountryAlpha2};
assert_eq!(Country::from(CountryAlpha2::ES).short_name(), "Spain");
use countries_tools::{Country, CountryAlpha3};
assert_eq!(Country::from(CountryAlpha3::USA).short_name(), "United States of America");
use countries_tools::Country;
assert_eq!(Country::try_from(392).unwrap().short_name(), "Japan");
As much methods as possible are const fn
to allow compile-time computation and optimize runtime performance.
Also this crate is no_std
compatible. The crate size is kept as small as possible and also the impact on the binary size.