Struct icu::locale::extensions::Extensions
source · #[non_exhaustive]pub struct Extensions {
pub unicode: Unicode,
pub transform: Transform,
pub private: Private,
pub other: Vec<Other>,
}
Expand description
A map of extensions associated with a given Locale
.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.unicode: Unicode
A representation of the data for a Unicode extension, when present in the locale identifier.
transform: Transform
A representation of the data for a transform extension, when present in the locale identifier.
private: Private
A representation of the data for a private-use extension, when present in the locale identifier.
other: Vec<Other>
A sequence of any other extensions that are present in the locale identifier but are not formally
defined and represented explicitly as Unicode
, Transform
,
and Private
are.
Implementations§
source§impl Extensions
impl Extensions
sourcepub const fn new() -> Extensions
pub const fn new() -> Extensions
sourcepub const fn from_unicode(unicode: Unicode) -> Extensions
pub const fn from_unicode(unicode: Unicode) -> Extensions
Function to create a new map of extensions containing exactly one unicode extension, callable in const
context.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether there are no extensions present.
§Examples
use icu::locale::Locale;
let loc: Locale = "en-US-u-foo".parse().expect("Parsing failed.");
assert!(!loc.extensions.is_empty());
sourcepub fn total_cmp(&self, other: &Extensions) -> Ordering
pub fn total_cmp(&self, other: &Extensions) -> Ordering
Returns an ordering suitable for use in BTreeSet
.
The ordering may or may not be equivalent to string ordering, and it may or may not be stable across ICU4X releases.
sourcepub fn retain_by_type<F>(&mut self, predicate: F)
pub fn retain_by_type<F>(&mut self, predicate: F)
Retains the specified extension types, clearing all others.
§Examples
use icu::locale::extensions::ExtensionType;
use icu::locale::Locale;
let loc: Locale =
"und-a-hello-t-mul-u-world-z-zzz-x-extra".parse().unwrap();
let mut only_unicode = loc.clone();
only_unicode
.extensions
.retain_by_type(|t| t == ExtensionType::Unicode);
assert_eq!(only_unicode, "und-u-world".parse().unwrap());
let mut only_t_z = loc.clone();
only_t_z.extensions.retain_by_type(|t| {
t == ExtensionType::Transform || t == ExtensionType::Other(b'z')
});
assert_eq!(only_t_z, "und-t-mul-z-zzz".parse().unwrap());
Trait Implementations§
source§impl Clone for Extensions
impl Clone for Extensions
source§fn clone(&self) -> Extensions
fn clone(&self) -> Extensions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Extensions
impl Debug for Extensions
source§impl Default for Extensions
impl Default for Extensions
source§fn default() -> Extensions
fn default() -> Extensions
source§impl Display for Extensions
impl Display for Extensions
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
source§impl Hash for Extensions
impl Hash for Extensions
source§impl PartialEq for Extensions
impl PartialEq for Extensions
source§impl Writeable for Extensions
impl Writeable for Extensions
source§fn write_to<W>(&self, sink: &mut W) -> Result<(), Error>
fn write_to<W>(&self, sink: &mut W) -> Result<(), Error>
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.impl Eq for Extensions
impl StructuralPartialEq for Extensions
Auto Trait Implementations§
impl Freeze for Extensions
impl RefUnwindSafe for Extensions
impl Send for Extensions
impl Sync for Extensions
impl Unpin for Extensions
impl UnwindSafe for Extensions
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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