#[non_exhaustive]pub struct Extensions {
pub unicode: Unicode,
pub transform: Transform,
pub private: Private,
pub other: &'static [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: UnicodeA representation of the data for a Unicode extension, when present in the locale identifier.
transform: TransformA representation of the data for a transform extension, when present in the locale identifier.
private: PrivateA representation of the data for a private-use extension, when present in the locale identifier.
other: &'static [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 from_unicode(unicode: Unicode) -> Self
pub const fn from_unicode(unicode: Unicode) -> Self
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: &Self) -> Ordering
pub fn total_cmp(&self, other: &Self) -> 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 more