pub struct Value(_);
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, extensions_unicode_value as 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(), "");
Implementations§
source§impl Value
impl Value
sourcepub fn try_from_bytes(input: &[u8]) -> Result<Value, ParserError>
pub fn try_from_bytes(input: &[u8]) -> Result<Value, ParserError>
sourcepub const fn try_from_single_subtag(subtag: &[u8]) -> Result<Value, ParserError>
pub const fn try_from_single_subtag(subtag: &[u8]) -> Result<Value, 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");
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<Value> for Value
impl PartialEq<Value> for Value
source§impl PartialOrd<Value> for Value
impl PartialOrd<Value> 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>(&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.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