pub struct Value(ShortBoxSlice<TinyAsciiStr<{ _ }>>);
Expand description
A value used in a list of Keywords
.
The value has to be a sequence of one or more alphanumerical strings
separated by -
.
Each part of the sequence has to be no shorter than three characters and no
longer than 8.
§Examples
use icu::locid::extensions::unicode::{value, Value};
use writeable::assert_writeable_eq;
assert_writeable_eq!(value!("gregory"), "gregory");
assert_writeable_eq!(
"islamic-civil".parse::<Value>().unwrap(),
"islamic-civil"
);
// The value "true" has the special, empty string representation
assert_eq!(value!("true").to_string(), "");
Tuple Fields§
§0: ShortBoxSlice<TinyAsciiStr<{ _ }>>
Implementations§
source§impl Value
impl Value
sourcepub fn try_from_bytes(input: &[u8]) -> Result<Self, ParserError>
pub fn try_from_bytes(input: &[u8]) -> Result<Self, ParserError>
sourcepub const fn try_from_single_subtag(subtag: &[u8]) -> Result<Self, ParserError>
pub const fn try_from_single_subtag(subtag: &[u8]) -> Result<Self, ParserError>
Const constructor for when the value contains only a single subtag.
§Examples
use icu::locid::extensions::unicode::Value;
Value::try_from_single_subtag(b"buddhist").expect("valid subtag");
Value::try_from_single_subtag(b"#####").expect_err("invalid subtag");
Value::try_from_single_subtag(b"foo-bar").expect_err("not a single subtag");
pub(crate) fn from_short_slice_unchecked( input: ShortBoxSlice<TinyAsciiStr<8>>, ) -> Self
pub(crate) fn parse_subtag( t: &[u8], ) -> Result<Option<TinyAsciiStr<8>>, ParserError>
pub(crate) const fn parse_subtag_from_bytes_manual_slice( bytes: &[u8], start: usize, end: usize, ) -> Result<Option<TinyAsciiStr<8>>, ParserError>
pub(crate) fn for_each_subtag_str<E, F>(&self, f: &mut F) -> Result<(), E>
Trait Implementations§
source§impl Display for Value
impl Display for Value
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
source§impl Ord for Value
impl Ord for Value
source§impl PartialEq for Value
impl PartialEq for Value
source§impl PartialOrd for Value
impl PartialOrd for Value
1.0.0 · source§fn 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 moresource§impl Writeable for Value
impl Writeable for Value
source§fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
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.source§fn 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
source§fn 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 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,
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.impl Eq for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
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
Mutably borrows from an owned value. Read more