Struct icu_locale::extensions::unicode::SubdivisionId
#[non_exhaustive]pub struct SubdivisionId {
pub region: Region,
pub suffix: SubdivisionSuffix,
}
Expand description
A Subivision Id as defined in Unicode Locale Identifier
.
Subdivision Id is used in Unicode
extensions:
rg
- Regional Overridesd
- Regional Subdivision
In both cases the subdivision is composed of a Region
and a SubdivisionSuffix
which represents
different meaning depending on the key.
§Examples
use icu::locale::{
subtags::region,
extensions::unicode::{subdivision_suffix, SubdivisionId}
};
let ss = subdivision_suffix!("zzzz");
let region = region!("gb");
let si = SubdivisionId::new(region, ss);
assert_eq!(si.to_string(), "gbzzzz");
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.region: Region
A region field of a Subdivision Id.
suffix: SubdivisionSuffix
A subdivision suffix field of a Subdivision Id.
Implementations§
§impl SubdivisionId
impl SubdivisionId
pub const fn new(region: Region, suffix: SubdivisionSuffix) -> SubdivisionId
pub const fn new(region: Region, suffix: SubdivisionSuffix) -> SubdivisionId
Returns a new SubdivisionId
.
§Examples
use icu::locale::{
subtags::region,
extensions::unicode::{subdivision_suffix, SubdivisionId}
};
let ss = subdivision_suffix!("zzzz");
let region = region!("gb");
let si = SubdivisionId::new(region, ss);
assert_eq!(si.to_string(), "gbzzzz");
pub fn try_from_str(s: &str) -> Result<SubdivisionId, ParseError>
pub fn try_from_str(s: &str) -> Result<SubdivisionId, ParseError>
A constructor which takes a str slice, parses it and
produces a well-formed SubdivisionId
.
pub fn try_from_utf8(code_units: &[u8]) -> Result<SubdivisionId, ParseError>
pub fn try_from_utf8(code_units: &[u8]) -> Result<SubdivisionId, ParseError>
pub fn into_subtag(self) -> Subtag
pub fn into_subtag(self) -> Subtag
Convert to Subtag
Trait Implementations§
§impl Clone for SubdivisionId
impl Clone for SubdivisionId
§fn clone(&self) -> SubdivisionId
fn clone(&self) -> SubdivisionId
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl Debug for SubdivisionId
impl Debug for SubdivisionId
§impl Display for SubdivisionId
impl Display for SubdivisionId
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
§impl FromStr for SubdivisionId
impl FromStr for SubdivisionId
§type Err = ParseError
type Err = ParseError
The associated error which can be returned from parsing.
§fn from_str(s: &str) -> Result<SubdivisionId, <SubdivisionId as FromStr>::Err>
fn from_str(s: &str) -> Result<SubdivisionId, <SubdivisionId as FromStr>::Err>
Parses a string
s
to return a value of this type. Read more§impl Hash for SubdivisionId
impl Hash for SubdivisionId
§impl Ord for SubdivisionId
impl Ord for SubdivisionId
§impl PartialEq for SubdivisionId
impl PartialEq for SubdivisionId
§impl PartialOrd for SubdivisionId
impl PartialOrd for SubdivisionId
§impl Writeable for SubdivisionId
impl Writeable for SubdivisionId
§fn write_to<W>(&self, sink: &mut W) -> Result<(), Error>
fn write_to<W>(&self, sink: &mut W) -> Result<(), Error>
Writes a string to the given sink. Errors from the sink are bubbled up.
The default implementation delegates to
write_to_parts
, and discards any
Part
annotations.§fn writeable_length_hint(&self) -> LengthHint
fn writeable_length_hint(&self) -> LengthHint
Returns a hint for the number of UTF-8 bytes that will be written to the sink. Read more
§fn write_to_parts<S>(&self, sink: &mut S) -> Result<(), Error>where
S: PartsWrite + ?Sized,
fn write_to_parts<S>(&self, sink: &mut S) -> Result<(), Error>where
S: PartsWrite + ?Sized,
Write bytes and
Part
annotations to the given sink. Errors from the
sink are bubbled up. The default implementation delegates to write_to
,
and doesn’t produce any Part
annotations.§fn write_to_string(&self) -> Cow<'_, str>
fn write_to_string(&self) -> Cow<'_, str>
Creates a new
String
with the data from this Writeable
. Like ToString
,
but smaller and faster. Read moreimpl Eq for SubdivisionId
impl StructuralPartialEq for SubdivisionId
Auto Trait Implementations§
impl Freeze for SubdivisionId
impl RefUnwindSafe for SubdivisionId
impl Send for SubdivisionId
impl Sync for SubdivisionId
impl Unpin for SubdivisionId
impl UnwindSafe for SubdivisionId
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more