Function keshvar::find_by_code

source ·
pub fn find_by_code(code: usize) -> Result<Country, SearchError>
Expand description

Find by country code.

You need to enable search-country-code feature to use this function.

§Memory notes

If you enabling this feature, Keshvar creates a global lazy_static hashmap and keeps all of included country codes in it.

§Example

use keshvar::{Alpha2, Country, find_by_code};

let country_code = 880; // The People's Republic of Bangladesh (Asia)
assert_eq!(Ok(Country::from(Alpha2::BD)), find_by_code(country_code));