pub struct SubdivisionSuffix(/* private fields */);
Expand description
A subdivision suffix used in SubdivisionId
.
This suffix represents a specific subdivision code under a given Region
.
For example the value of SubdivisionId
may be gbsct
, where the SubdivisionSuffix
is sct
for Scotland.
Such a value associated with a key rg
means that the locale should use Unit Preferences
(default calendar, currency, week data, time cycle, measurement system) for Scotland, even if the
LanguageIdentifier
is en-US
.
A subdivision suffix has to be a sequence of alphanumerical characters no shorter than one and no longer than four characters.
§Examples
use icu::locale::extensions::unicode::{subdivision_suffix, SubdivisionSuffix};
let ss: SubdivisionSuffix =
"sct".parse().expect("Failed to parse a SubdivisionSuffix.");
assert_eq!(ss, subdivision_suffix!("sct"));
Implementations§
Source§impl SubdivisionSuffix
impl SubdivisionSuffix
Sourcepub const fn try_from_str(s: &str) -> Result<Self, ParseError>
pub const fn try_from_str(s: &str) -> Result<Self, ParseError>
A constructor which takes a str slice, parses it and
produces a well-formed SubdivisionSuffix
.
§Examples
use icu_locale_core::extensions :: unicode ::SubdivisionSuffix;
assert!(SubdivisionSuffix::try_from_str("sct").is_ok());
assert!(SubdivisionSuffix::try_from_str("toolooong").is_err());
Sourcepub const fn try_from_utf8(code_units: &[u8]) -> Result<Self, ParseError>
pub const fn try_from_utf8(code_units: &[u8]) -> Result<Self, ParseError>
Sourcepub const fn try_from_raw(raw: [u8; 4]) -> Result<Self, ParseError>
pub const fn try_from_raw(raw: [u8; 4]) -> Result<Self, ParseError>
Safely creates a SubdivisionSuffix
from its raw format
as returned by Self::into_raw
. Unlike Self::try_from_utf8
,
this constructor only takes normalized values.
Sourcepub const unsafe fn from_raw_unchecked(v: [u8; 4]) -> Self
pub const unsafe fn from_raw_unchecked(v: [u8; 4]) -> Self
Unsafely creates a SubdivisionSuffix
from its raw format
as returned by Self::into_raw
. Unlike Self::try_from_utf8
,
this constructor only takes normalized values.
§Safety
This function is safe iff Self::try_from_raw
returns an Ok
. This is the case
for inputs that are correctly normalized.
Sourcepub const fn into_raw(self) -> [u8; 4]
pub const fn into_raw(self) -> [u8; 4]
Deconstructs into a raw format to be consumed by
from_raw_unchecked
or
try_from_raw
.
Sourcepub fn strict_cmp(self, other: &[u8]) -> Ordering
pub fn strict_cmp(self, other: &[u8]) -> Ordering
Compare with BCP-47 bytes.
The return value is equivalent to what would happen if you first converted
self
to a BCP-47 string and then performed a byte comparison.
This function is case-sensitive and results in a total order, so it is appropriate for
binary search. The only argument producing Ordering::Equal
is self.as_str().as_bytes()
.
Sourcepub fn normalizing_eq(self, other: &str) -> bool
pub fn normalizing_eq(self, other: &str) -> bool
Compare with a potentially unnormalized BCP-47 string.
The return value is equivalent to what would happen if you first parsed the BCP-47 string and then performed a structural comparison.
Trait Implementations§
Source§impl AsULE for SubdivisionSuffix
impl AsULE for SubdivisionSuffix
Source§type ULE = SubdivisionSuffix
type ULE = SubdivisionSuffix
Self
. Read moreSource§fn to_unaligned(self) -> Self::ULE
fn to_unaligned(self) -> Self::ULE
Source§fn from_unaligned(unaligned: Self::ULE) -> Self
fn from_unaligned(unaligned: Self::ULE) -> Self
Source§impl Clone for SubdivisionSuffix
impl Clone for SubdivisionSuffix
Source§fn clone(&self) -> SubdivisionSuffix
fn clone(&self) -> SubdivisionSuffix
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SubdivisionSuffix
impl Debug for SubdivisionSuffix
Source§impl Display for SubdivisionSuffix
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for SubdivisionSuffix
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
Source§impl<'l> From<&'l SubdivisionSuffix> for &'l str
impl<'l> From<&'l SubdivisionSuffix> for &'l str
Source§fn from(input: &'l SubdivisionSuffix) -> Self
fn from(input: &'l SubdivisionSuffix) -> Self
Source§impl From<SubdivisionSuffix> for TinyAsciiStr<4>
impl From<SubdivisionSuffix> for TinyAsciiStr<4>
Source§fn from(input: SubdivisionSuffix) -> Self
fn from(input: SubdivisionSuffix) -> Self
Source§impl FromStr for SubdivisionSuffix
impl FromStr for SubdivisionSuffix
Source§impl Hash for SubdivisionSuffix
impl Hash for SubdivisionSuffix
Source§impl NicheBytes<4> for SubdivisionSuffix
impl NicheBytes<4> for SubdivisionSuffix
const NICHE_BIT_PATTERN: [u8; 4] = tinystr::TinyAsciiStr<4>::NICHE_BIT_PATTERN
Source§impl Ord for SubdivisionSuffix
impl Ord for SubdivisionSuffix
Source§fn cmp(&self, other: &SubdivisionSuffix) -> Ordering
fn cmp(&self, other: &SubdivisionSuffix) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for SubdivisionSuffix
impl PartialEq for SubdivisionSuffix
Source§impl PartialOrd for SubdivisionSuffix
impl PartialOrd for SubdivisionSuffix
Source§impl ULE for SubdivisionSuffix
impl ULE for SubdivisionSuffix
Source§fn validate_bytes(bytes: &[u8]) -> Result<(), UleError>
fn validate_bytes(bytes: &[u8]) -> Result<(), UleError>
&[u8]
. Read moreSource§unsafe fn slice_from_bytes_unchecked(bytes: &[u8]) -> &[Self]
unsafe fn slice_from_bytes_unchecked(bytes: &[u8]) -> &[Self]
&[u8]
, and return it as &[Self]
with the same lifetime, assuming
that this byte slice has previously been run through Self::parse_bytes_to_slice()
with
success. Read moreSource§impl Writeable for SubdivisionSuffix
impl Writeable for SubdivisionSuffix
Source§fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
write_to_parts
, and discards any
Part
annotations.Source§fn writeable_length_hint(&self) -> LengthHint
fn writeable_length_hint(&self) -> LengthHint
Source§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,
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.Source§impl<'a> ZeroMapKV<'a> for SubdivisionSuffix
impl<'a> ZeroMapKV<'a> for SubdivisionSuffix
Source§type Container = ZeroVec<'a, SubdivisionSuffix>
type Container = ZeroVec<'a, SubdivisionSuffix>
ZeroVec
or VarZeroVec
.type Slice = ZeroSlice<SubdivisionSuffix>
Source§type GetType = SubdivisionSuffix
type GetType = SubdivisionSuffix
Container::get()
Read moreSource§type OwnedType = SubdivisionSuffix
type OwnedType = SubdivisionSuffix
Container::replace()
and Container::remove()
,
also used during deserialization. If Self
is human readable serialized,
deserializing to Self::OwnedType
should produce the same value once
passed through Self::owned_as_self()
Read more