pub struct Other { /* private fields */ }Expand description
A list of Other Use Extensions as defined in Unicode Locale Identifier specification.
Those extensions are treated as a pass-through, and no Unicode related behavior depends on them.
§Examples
use icu::locale::extensions::other::Other;
use icu::locale::subtags::Subtag;
let subtag1: Subtag = "foo".parse().expect("Failed to parse a Subtag.");
let subtag2: Subtag = "bar".parse().expect("Failed to parse a Subtag.");
let other = Other::from_vec_unchecked(b'a', vec![subtag1, subtag2]);
assert_eq!(&other.to_string(), "a-foo-bar");Implementations§
Source§impl Other
impl Other
Sourcepub fn try_from_str(s: &str) -> Result<Self, ParseError>
pub fn try_from_str(s: &str) -> Result<Self, ParseError>
A constructor which takes a str slice, parses it and
produces a well-formed Other.
✨ Enabled with the alloc Cargo feature.
Sourcepub fn try_from_utf8(code_units: &[u8]) -> Result<Self, ParseError>
pub fn try_from_utf8(code_units: &[u8]) -> Result<Self, ParseError>
✨ Enabled with the alloc Cargo feature.
Sourcepub fn from_vec_unchecked(ext: u8, keys: Vec<Subtag>) -> Self
pub fn from_vec_unchecked(ext: u8, keys: Vec<Subtag>) -> Self
A constructor which takes a pre-sorted list of Subtag.
✨ Enabled with the alloc Cargo feature.
§Panics
Panics if ext is not ASCII alphabetic.
§Examples
use icu::locale::extensions::other::Other;
use icu::locale::subtags::Subtag;
let subtag1: Subtag = "foo".parse().expect("Failed to parse a Subtag.");
let subtag2: Subtag = "bar".parse().expect("Failed to parse a Subtag.");
let other = Other::from_vec_unchecked(b'a', vec![subtag1, subtag2]);
assert_eq!(&other.to_string(), "a-foo-bar");Sourcepub fn get_ext_str(&self) -> &str
pub fn get_ext_str(&self) -> &str
Gets the tag character for this extension as a &str.
§Examples
use icu::locale::Locale;
let loc: Locale = "und-a-hello-world".parse().unwrap();
let other_ext = &loc.extensions.other[0];
assert_eq!(other_ext.get_ext_str(), "a");Sourcepub fn get_ext(&self) -> char
pub fn get_ext(&self) -> char
Gets the tag character for this extension as a char.
§Examples
use icu::locale::Locale;
let loc: Locale = "und-a-hello-world".parse().unwrap();
let other_ext = &loc.extensions.other[0];
assert_eq!(other_ext.get_ext(), 'a');Sourcepub fn get_ext_byte(&self) -> u8
pub fn get_ext_byte(&self) -> u8
Gets the tag character for this extension as a byte.
§Examples
use icu::locale::Locale;
let loc: Locale = "und-a-hello-world".parse().unwrap();
let other_ext = &loc.extensions.other[0];
assert_eq!(other_ext.get_ext_byte(), b'a');Trait Implementations§
Source§impl Display for Other
This trait is implemented for compatibility with fmt!.
To create a string, [Writeable::write_to_string] is usually more efficient.
impl Display for Other
This trait is implemented for compatibility with fmt!.
To create a string, [Writeable::write_to_string] is usually more efficient.
Source§impl FromStr for Other
Available on crate feature alloc only.✨ Enabled with the alloc Cargo feature.
impl FromStr for Other
alloc only.✨ Enabled with the alloc Cargo feature.
Source§impl Ord for Other
impl Ord for Other
Source§impl PartialOrd for Other
impl PartialOrd for Other
Source§impl Writeable for Other
impl Writeable for Other
Source§fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
write_to_parts, and discards any
Part annotations.Source§fn writeable_length_hint(&self) -> LengthHint
fn writeable_length_hint(&self) -> LengthHint
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_borrow(&self) -> Option<&str>
fn writeable_borrow(&self) -> Option<&str>
impl Eq for Other
impl StructuralPartialEq for Other
Auto Trait Implementations§
impl Freeze for Other
impl RefUnwindSafe for Other
impl Send for Other
impl Sync for Other
impl Unpin for Other
impl UnwindSafe for Other
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more