Struct icu::locale::extensions::unicode::SubdivisionSuffix
source · 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<SubdivisionSuffix, ParseError>
pub const fn try_from_str(s: &str) -> Result<SubdivisionSuffix, 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<SubdivisionSuffix, ParseError>
pub const fn try_from_utf8( code_units: &[u8], ) -> Result<SubdivisionSuffix, ParseError>
sourcepub const fn try_from_raw(raw: [u8; 4]) -> Result<SubdivisionSuffix, ParseError>
pub const fn try_from_raw(raw: [u8; 4]) -> Result<SubdivisionSuffix, 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]) -> SubdivisionSuffix
pub const unsafe fn from_raw_unchecked(v: [u8; 4]) -> SubdivisionSuffix
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) -> <SubdivisionSuffix as AsULE>::ULE
fn to_unaligned(self) -> <SubdivisionSuffix as AsULE>::ULE
source§fn from_unaligned(
unaligned: <SubdivisionSuffix as AsULE>::ULE,
) -> SubdivisionSuffix
fn from_unaligned( unaligned: <SubdivisionSuffix as AsULE>::ULE, ) -> SubdivisionSuffix
source§impl Bake for SubdivisionSuffix
impl Bake for SubdivisionSuffix
source§fn bake(&self, env: &CrateEnv) -> TokenStream
fn bake(&self, env: &CrateEnv) -> TokenStream
source§impl BakeSize for SubdivisionSuffix
impl BakeSize for SubdivisionSuffix
source§fn borrows_size(&self) -> usize
fn borrows_size(&self) -> usize
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<'de> Deserialize<'de> for SubdivisionSuffix
impl<'de> Deserialize<'de> for SubdivisionSuffix
source§fn deserialize<D>(
deserializer: D,
) -> Result<SubdivisionSuffix, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<SubdivisionSuffix, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl Display for SubdivisionSuffix
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) -> &'l str
fn from(input: &'l SubdivisionSuffix) -> &'l str
source§impl From<SubdivisionSuffix> for TinyAsciiStr<4>
impl From<SubdivisionSuffix> for TinyAsciiStr<4>
source§fn from(input: SubdivisionSuffix) -> TinyAsciiStr<4>
fn from(input: SubdivisionSuffix) -> TinyAsciiStr<4>
source§impl FromStr for SubdivisionSuffix
impl FromStr for SubdivisionSuffix
source§type Err = ParseError
type Err = ParseError
source§fn from_str(
s: &str,
) -> Result<SubdivisionSuffix, <SubdivisionSuffix as FromStr>::Err>
fn from_str( s: &str, ) -> Result<SubdivisionSuffix, <SubdivisionSuffix as FromStr>::Err>
s
to return a value of this type. Read moresource§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 Serialize for SubdivisionSuffix
impl Serialize for SubdivisionSuffix
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
source§impl ULE for SubdivisionSuffix
impl ULE for SubdivisionSuffix
source§fn validate_byte_slice(bytes: &[u8]) -> Result<(), UleError>
fn validate_byte_slice(bytes: &[u8]) -> Result<(), UleError>
&[u8]
. Read moresource§unsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &[Self]
unsafe fn from_byte_slice_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_byte_slice()
with
success. Read moresource§impl Writeable for SubdivisionSuffix
impl Writeable for SubdivisionSuffix
source§fn write_to<W>(&self, sink: &mut W) -> Result<(), Error>
fn write_to<W>(&self, sink: &mut W) -> Result<(), Error>
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_string(&self) -> Cow<'_, str>
fn write_to_string(&self) -> Cow<'_, str>
String
with the data from this Writeable
. Like ToString
,
but smaller and faster. Read moresource§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 moreimpl Copy for SubdivisionSuffix
impl Eq for SubdivisionSuffix
impl StructuralPartialEq for SubdivisionSuffix
Auto Trait Implementations§
impl Freeze for SubdivisionSuffix
impl RefUnwindSafe for SubdivisionSuffix
impl Send for SubdivisionSuffix
impl Sync for SubdivisionSuffix
impl Unpin for SubdivisionSuffix
impl UnwindSafe for SubdivisionSuffix
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
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)
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>
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>
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