#[repr(transparent)]pub struct Subtag(_);
Expand description
A single item used in a list of Private
extensions.
The subtag has to be an ASCII alphanumerical string no shorter than one character and no longer than eight.
Examples
use icu::locid::extensions::private::Subtag;
let subtag1: Subtag = "Foo".parse().expect("Failed to parse a Subtag.");
assert_eq!(subtag1.as_str(), "foo");
Implementations
sourceimpl Subtag
impl Subtag
sourcepub const fn try_from_bytes(v: &[u8]) -> Result<Subtag, ParserError>
pub const fn try_from_bytes(v: &[u8]) -> Result<Subtag, ParserError>
sourcepub const fn try_from_bytes_manual_slice(
v: &[u8],
start: usize,
end: usize
) -> Result<Subtag, ParserError>
pub const fn try_from_bytes_manual_slice(
v: &[u8],
start: usize,
end: usize
) -> Result<Subtag, ParserError>
Equivalent to try_from_bytes(bytes[start..end])
,
but callable in a const
context (which range indexing is not).
sourcepub const fn try_from_raw(v: [u8; 8]) -> Result<Subtag, ParserError>
pub const fn try_from_raw(v: [u8; 8]) -> Result<Subtag, ParserError>
Safely creates a Subtag
from its raw format
as returned by Self::into_raw
. Unlike Self::try_from_bytes
,
this constructor only takes normalized values.
sourcepub const unsafe fn from_raw_unchecked(v: [u8; 8]) -> Subtag
pub const unsafe fn from_raw_unchecked(v: [u8; 8]) -> Subtag
Unsafely creates a Subtag
from its raw format
as returned by Self::into_raw
. Unlike Self::try_from_bytes
,
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; 8]
pub const fn into_raw(self) -> [u8; 8]
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
sourceimpl Bake for Subtag
impl Bake for Subtag
sourcefn bake(&self, env: &CrateEnv) -> TokenStream
fn bake(&self, env: &CrateEnv) -> TokenStream
Returns a TokenStream
that would evaluate to self
. Read more
sourceimpl<'de> Deserialize<'de> for Subtag
impl<'de> Deserialize<'de> for Subtag
sourcefn deserialize<D>(
deserializer: D
) -> Result<Subtag, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<Subtag, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for Subtag
impl Display for Subtag
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
sourceimpl Ord for Subtag
impl Ord for Subtag
sourceimpl PartialOrd<Subtag> for Subtag
impl PartialOrd<Subtag> for Subtag
sourcefn partial_cmp(&self, other: &Subtag) -> Option<Ordering>
fn partial_cmp(&self, other: &Subtag) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl Serialize for Subtag
impl Serialize for Subtag
sourcefn 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,
Serialize this value into the given Serde serializer. Read more
sourceimpl ULE for Subtag
impl ULE for Subtag
sourcefn validate_byte_slice(bytes: &[u8]) -> Result<(), ZeroVecError>
fn validate_byte_slice(bytes: &[u8]) -> Result<(), ZeroVecError>
Validates a byte slice, &[u8]
. Read more
sourcefn parse_byte_slice(bytes: &[u8]) -> Result<&[Self], ZeroVecError>
fn parse_byte_slice(bytes: &[u8]) -> Result<&[Self], ZeroVecError>
Parses a byte slice, &[u8]
, and return it as &[Self]
with the same lifetime. Read more
sourceunsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &[Self]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
unsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &[Self]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Takes a byte slice, &[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 more
sourceimpl Writeable for Subtag
impl Writeable for Subtag
sourcefn write_to<W>(&self, sink: &mut W) -> Result<(), Error> where
W: Write + ?Sized,
fn write_to<W>(&self, sink: &mut W) -> Result<(), Error> where
W: Write + ?Sized,
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. Read more
sourcefn 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
sourcefn 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 more
sourcefn 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. Read more
sourceimpl<'a> ZeroMapKV<'a> for Subtag
impl<'a> ZeroMapKV<'a> for Subtag
impl Copy for Subtag
impl Eq for Subtag
impl StructuralEq for Subtag
impl StructuralPartialEq for Subtag
Auto Trait Implementations
impl RefUnwindSafe for Subtag
impl Send for Subtag
impl Sync for Subtag
impl Unpin for Subtag
impl UnwindSafe for Subtag
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Separable for T where
T: Display,
impl<T> Separable for T where
T: Display,
sourcefn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
Adds separators according to the given SeparatorPolicy
. Read more
sourcefn separate_with_commas(&self) -> String
fn separate_with_commas(&self) -> String
Inserts a comma every three digits from the right. Read more
sourcefn separate_with_spaces(&self) -> String
fn separate_with_spaces(&self) -> String
Inserts a space every three digits from the right. Read more
sourcefn separate_with_dots(&self) -> String
fn separate_with_dots(&self) -> String
Inserts a period every three digits from the right. Read more
sourcefn separate_with_underscores(&self) -> String
fn separate_with_underscores(&self) -> String
Inserts an underscore every three digits from the right. Read more
sourceimpl<T> Serialize for T where
T: Serialize + ?Sized,
impl<T> Serialize for T where
T: Serialize + ?Sized,
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more