Struct icu::locid::subtags::Region [−][src]
pub struct Region(_);
A region subtag (examples: "US"
, "CN"
, "AR"
etc.)
Region
represents a Unicode base language code conformat to the
unicode_region_id
field of the Language and Locale Identifier.
Examples
use icu::locid::subtags::Region; let region: Region = "DE".parse() .expect("Failed to parse a region subtag.");
Implementations
impl Region
[src]
impl Region
[src]pub fn from_bytes(v: &[u8]) -> Result<Region, ParserError>
[src]
A constructor which takes a utf8 slice, parses it and
produces a well-formed Region
.
Examples
use icu::locid::subtags::Region; let region = Region::from_bytes(b"fr") .expect("Parsing failed."); assert_eq!(region, "FR");
pub fn into_raw(self) -> u32
[src]
Deconstructs the Region
into raw format to be consumed
by from_raw_unchecked()
.
Examples
use icu::locid::subtags::Region; let region = Region::from_bytes(b"us") .expect("Parsing failed."); let raw = region.into_raw(); let region = unsafe { Region::from_raw_unchecked(raw) }; assert_eq!(region, "US");
pub const unsafe fn from_raw_unchecked(v: u32) -> Region
[src]
Constructor which takes a raw value returned by
into_raw()
.
Examples
use icu::locid::subtags::Region; let region = Region::from_bytes(b"us") .expect("Parsing failed."); let raw = region.into_raw(); let region = unsafe { Region::from_raw_unchecked(raw) }; assert_eq!(region, "US");
Safety
This function accepts a u32
that is expected to be a valid [TinyStr4
]
representing a Region
subtag in canonical syntax.
pub fn as_str(&self) -> &str
[src]
A helper function for displaying
a Region
subtag as a &
str
.
Examples
use icu::locid::subtags::Region; let region = Region::from_bytes(b"it") .expect("Parsing failed."); assert_eq!(region.as_str(), "IT");
Notice
: For many use cases, such as comparison,
Region
implements PartialEq
<&
str
>
which allows for direct comparisons.
Trait Implementations
impl PartialOrd<Region> for Region
[src]
impl PartialOrd<Region> for Region
[src]impl StructuralEq for Region
[src]
impl StructuralEq for Region
[src]impl StructuralPartialEq for Region
[src]
impl StructuralPartialEq for Region
[src]Auto Trait Implementations
impl RefUnwindSafe for Region
impl RefUnwindSafe for Region
impl UnwindSafe for Region
impl UnwindSafe for Region