Struct icu_locale::extensions::unicode::SubdivisionSuffix
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§
§impl SubdivisionSuffix
impl SubdivisionSuffix
pub 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());
pub const fn try_from_utf8(
code_units: &[u8],
) -> Result<SubdivisionSuffix, ParseError>
pub const fn try_from_utf8( code_units: &[u8], ) -> Result<SubdivisionSuffix, ParseError>
pub 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.
pub 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.
pub 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
.
pub 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()
.
pub 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§
§impl AsULE for SubdivisionSuffix
impl AsULE for SubdivisionSuffix
§type ULE = SubdivisionSuffix
type ULE = SubdivisionSuffix
Self
. Read more§fn to_unaligned(self) -> <SubdivisionSuffix as AsULE>::ULE
fn to_unaligned(self) -> <SubdivisionSuffix as AsULE>::ULE
§fn from_unaligned(
unaligned: <SubdivisionSuffix as AsULE>::ULE,
) -> SubdivisionSuffix
fn from_unaligned( unaligned: <SubdivisionSuffix as AsULE>::ULE, ) -> SubdivisionSuffix
§impl Bake for SubdivisionSuffix
impl Bake for SubdivisionSuffix
§fn bake(&self, env: &CrateEnv) -> TokenStream
fn bake(&self, env: &CrateEnv) -> TokenStream
§impl BakeSize for SubdivisionSuffix
impl BakeSize for SubdivisionSuffix
§fn borrows_size(&self) -> usize
fn borrows_size(&self) -> usize
§impl Clone for SubdivisionSuffix
impl Clone for SubdivisionSuffix
§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 more§impl Debug for SubdivisionSuffix
impl Debug for SubdivisionSuffix
§impl<'de> Deserialize<'de> for SubdivisionSuffix
impl<'de> Deserialize<'de> for SubdivisionSuffix
§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>,
§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.
§impl<'l> From<&'l SubdivisionSuffix> for &'l str
impl<'l> From<&'l SubdivisionSuffix> for &'l str
§fn from(input: &'l SubdivisionSuffix) -> &'l str
fn from(input: &'l SubdivisionSuffix) -> &'l str
§impl From<SubdivisionSuffix> for TinyAsciiStr<4>
impl From<SubdivisionSuffix> for TinyAsciiStr<4>
§fn from(input: SubdivisionSuffix) -> TinyAsciiStr<4>
fn from(input: SubdivisionSuffix) -> TinyAsciiStr<4>
§impl FromStr for SubdivisionSuffix
impl FromStr for SubdivisionSuffix
§type Err = ParseError
type Err = ParseError
§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 more§impl Hash for SubdivisionSuffix
impl Hash for SubdivisionSuffix
§impl NicheBytes<4> for SubdivisionSuffix
impl NicheBytes<4> for SubdivisionSuffix
const NICHE_BIT_PATTERN: [u8; 4] = tinystr::TinyAsciiStr<4>::NICHE_BIT_PATTERN
§impl Ord for SubdivisionSuffix
impl Ord for SubdivisionSuffix
§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,
§impl PartialEq for SubdivisionSuffix
impl PartialEq for SubdivisionSuffix
§impl PartialOrd for SubdivisionSuffix
impl PartialOrd for SubdivisionSuffix
§impl Serialize for SubdivisionSuffix
impl Serialize for SubdivisionSuffix
§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,
§impl ULE for SubdivisionSuffix
impl ULE for SubdivisionSuffix
§fn parse_bytes_to_slice(bytes: &[u8]) -> Result<&[Self], UleError>
fn parse_bytes_to_slice(bytes: &[u8]) -> Result<&[Self], UleError>
§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 more§fn slice_as_bytes(slice: &[Self]) -> &[u8] ⓘ
fn slice_as_bytes(slice: &[Self]) -> &[u8] ⓘ
§impl Writeable for SubdivisionSuffix
impl Writeable for SubdivisionSuffix
§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.§fn writeable_length_hint(&self) -> LengthHint
fn writeable_length_hint(&self) -> LengthHint
§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 more§impl<'a> ZeroMapKV<'a> for SubdivisionSuffix
impl<'a> ZeroMapKV<'a> for SubdivisionSuffix
§type Container = ZeroVec<'a, SubdivisionSuffix>
type Container = ZeroVec<'a, SubdivisionSuffix>
ZeroVec
] or [VarZeroVec
].type Slice = ZeroSlice<SubdivisionSuffix>
§type GetType = SubdivisionSuffix
type GetType = SubdivisionSuffix
Container::get()
Read more§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