pub struct Value(/* private fields */);
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(), "");
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");
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 PartialOrd for Value
impl PartialOrd for Value
Source§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)