#[repr(transparent)]pub struct Subtag(TinyAsciiStr<8>);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::locale::extensions::private::Subtag;
let subtag1: Subtag = "Foo".parse()
.expect("Failed to parse a Subtag.");
assert_eq!(subtag1.as_str(), "foo");Notice: This is different from the generic Subtag
which is between two and eight characters.
use icu::locale::extensions::private;
use icu::locale::subtags;
let subtag: Result<private::Subtag, _> = "f".parse();
assert!(subtag.is_ok());
let subtag: Result<subtags::Subtag, _> = "f".parse();
assert!(subtag.is_err());Tuple Fields§
§0: TinyAsciiStr<8>Implementations§
Source§impl Subtag
impl Subtag
Sourcepub const fn try_from_str(s: &str) -> Result<Subtag, ParseError>
pub const fn try_from_str(s: &str) -> Result<Subtag, ParseError>
Sourcepub const fn try_from_utf8(code_units: &[u8]) -> Result<Subtag, ParseError>
pub const fn try_from_utf8(code_units: &[u8]) -> Result<Subtag, ParseError>
Sourcepub const fn try_from_raw(raw: [u8; 8]) -> Result<Subtag, ParseError>
pub const fn try_from_raw(raw: [u8; 8]) -> Result<Subtag, ParseError>
Safely creates a Subtag 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; 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_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; 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§
Source§impl Display for Subtag
This trait is implemented for compatibility with fmt!.
To create a string, [Writeable::write_to_string] is usually more efficient.
impl Display for Subtag
This trait is implemented for compatibility with fmt!.
To create a string, [Writeable::write_to_string] is usually more efficient.
Source§impl From<Subtag> for TinyAsciiStr<8>
impl From<Subtag> for TinyAsciiStr<8>
Source§fn from(input: Subtag) -> TinyAsciiStr<8>
fn from(input: Subtag) -> TinyAsciiStr<8>
Source§impl NicheBytes<8> for Subtag
Available on crate feature zerovec only.
impl NicheBytes<8> for Subtag
zerovec only.const NICHE_BIT_PATTERN: [u8; 8] = tinystr::TinyAsciiStr<8>::NICHE_BIT_PATTERN
Source§impl Ord for Subtag
impl Ord for Subtag
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Subtag
impl PartialOrd for Subtag
Source§impl ULE for Subtag
Available on crate feature zerovec only.
impl ULE for Subtag
zerovec only.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 Subtag
impl Writeable for Subtag
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 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§fn writeable_length_hint(&self) -> LengthHint
fn writeable_length_hint(&self) -> LengthHint
Source§fn writeable_borrow(&self) -> Option<&str>
fn writeable_borrow(&self) -> Option<&str>
Source§impl<'a> ZeroMapKV<'a> for Subtag
Available on crate features zerovec and alloc only.
impl<'a> ZeroMapKV<'a> for Subtag
zerovec and alloc only.