Struct icu_locid::extensions::other::Other
source · pub struct Other {
ext: u8,
keys: ShortBoxSlice<Subtag>,
}
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::locid::extensions::other::{Other, 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");
Fields§
§ext: u8
§keys: ShortBoxSlice<Subtag>
Implementations§
source§impl Other
impl Other
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
.
§Panics
Panics if ext
is not ASCII alphabetic.
§Examples
use icu::locid::extensions::other::{Other, 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");
pub(crate) fn from_short_slice_unchecked( ext: u8, keys: ShortBoxSlice<Subtag>, ) -> Self
pub(crate) fn try_from_iter( ext: u8, iter: &mut SubtagIterator<'_>, ) -> Result<Self, ParserError>
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::locid::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::locid::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::locid::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');
pub(crate) fn for_each_subtag_str<E, F>(&self, f: &mut F) -> Result<(), E>
Trait Implementations§
source§impl Display for Other
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 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
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 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
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
)