pub struct Country {
pub name: &'static str,
pub capital: Option<&'static str>,
pub region: Option<&'static str>,
pub alpha_2: &'static str,
pub alpha_3: &'static str,
pub timezones: &'static [Timezone],
pub currencies: &'static [Currency],
pub languages: &'static [Language],
pub call_codes: &'static [&'static str],
}
Expand description
Represents a Country.
Fields§
§name: &'static str
Name of the country, eg. “United States”.
capital: Option<&'static str>
Name of the country’s capital, eg. “Washington, DC”.
region: Option<&'static str>
Region of the country
alpha_2: &'static str
ISO 3166-1 2-letter country code
alpha_3: &'static str
3166-1 3-letter country code
timezones: &'static [Timezone]
Timezones that country has in UTC, eg. UTC-05:00
for columbia
currencies: &'static [Currency]
Currencies used in the country
languages: &'static [Language]
Languages used in the country
call_codes: &'static [&'static str]
Dialling codes used in a country
Implementations§
Source§impl Country
impl Country
Sourcepub fn from_name(name: &str) -> Option<&'static Self>
pub fn from_name(name: &str) -> Option<&'static Self>
Get the country from it’s name
§Example
use iso_rs::prelude::*;
let country = Country::from_name("India").unwrap();
assert_eq!(country.capital.unwrap(), "New Delhi");
Sourcepub fn from_capital(capital: &str) -> Option<&'static [Self]>
pub fn from_capital(capital: &str) -> Option<&'static [Self]>
Get a list of countries from a capital
§Example
use iso_rs::prelude::*;
let country = Country::from_capital("New Delhi").unwrap()[0];
assert_eq!(country.name, "India");
Sourcepub fn from_region(region: &str) -> Option<&'static [Self]>
pub fn from_region(region: &str) -> Option<&'static [Self]>
Get a list of countries inside a region
§Example
use iso_rs::prelude::*;
let southern_asia = Country::from_region("Southern Asia").unwrap();
assert!(southern_asia.contains(Country::from_name("India").unwrap()));
Sourcepub fn from_alpha_2(alpha_2: &str) -> Option<&'static [Self]>
pub fn from_alpha_2(alpha_2: &str) -> Option<&'static [Self]>
Get the country from its ISO 3166-1 alpha_2 code
§Example
use iso_rs::prelude::*;
let mut country = Country::from_alpha_2("IN").unwrap();
assert_eq!(country[0], *Country::from_name("India").unwrap());
Sourcepub fn from_alpha_3(alpha_3: &str) -> Option<&'static [Self]>
pub fn from_alpha_3(alpha_3: &str) -> Option<&'static [Self]>
Get the country from its ISO 3166-1 alpha_3 code
§Example
use iso_rs::prelude::*;
let mut country = Country::from_alpha_3("IND").unwrap();
assert_eq!(country[0], *Country::from_name("India").unwrap());
Trait Implementations§
impl Copy for Country
impl Eq for Country
impl StructuralPartialEq for Country
Auto Trait Implementations§
impl Freeze for Country
impl RefUnwindSafe for Country
impl Send for Country
impl Sync for Country
impl Unpin for Country
impl UnwindSafe for Country
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more