pub struct Key(_);
Expand description
A key used in a list of Keywords
.
The key has to be a two ASCII alphanumerical characters long, with the first character being alphanumeric, and the second being alphabetic.
Examples
use icu::locid::extensions::unicode::Key;
let key1: Key = "ca".parse().expect("Failed to parse a Key.");
assert_eq!(key1.as_str(), "ca");
Implementations
sourceimpl Key
impl Key
sourcepub const fn from_bytes(key: &[u8]) -> Result<Self, ParserError>
pub const fn from_bytes(key: &[u8]) -> Result<Self, ParserError>
sourcepub fn from_tinystr_unchecked(key: TinyAsciiStr<KEY_LENGTH>) -> Self
pub fn from_tinystr_unchecked(key: TinyAsciiStr<KEY_LENGTH>) -> Self
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
A helper function for displaying
a Key
subtag as a &
str
.
Examples
use icu::locid::extensions::unicode::Key;
let key: Key = "ca".parse().expect("Parsing failed.");
assert_eq!(key.as_str(), "ca");
Notice
: For many use cases, such as comparison,
Key
implements PartialEq
<&
str
>
which allows for direct comparisons.
Trait Implementations
sourceimpl Ord for Key
impl Ord for Key
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Key> for Key
impl PartialOrd<Key> for Key
sourcefn partial_cmp(&self, other: &Key) -> Option<Ordering>
fn partial_cmp(&self, other: &Key) -> 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 Writeable for Key
impl Writeable for Key
sourcefn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
Writes bytes 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 write_len(&self) -> LengthHint
fn write_len(&self) -> LengthHint
Returns a hint for the number of bytes that will be written to the sink. 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
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
impl Copy for Key
impl Eq for Key
impl StructuralEq for Key
impl StructuralPartialEq for Key
Auto Trait Implementations
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnwindSafe for Key
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