Struct icu::locid::extensions::Extensions
source · [−]#[non_exhaustive]pub struct Extensions {
pub unicode: Unicode,
pub transform: Transform,
pub private: Private,
pub other: Vec<Other, Global>,
}
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, Global>
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
sourceimpl 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::locid::Locale;
let loc: Locale = "en-US-u-foo".parse().expect("Parsing failed.");
assert!(!loc.extensions.is_empty());
sourcepub fn retain_by_type<F>(&mut self, predicate: F) where
F: FnMut(ExtensionType) -> bool,
pub fn retain_by_type<F>(&mut self, predicate: F) where
F: FnMut(ExtensionType) -> bool,
Retains the specified extension types, clearing all others.
Examples
use icu::locid::extensions::ExtensionType;
use icu::locid::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
sourceimpl Clone for Extensions
impl Clone for Extensions
sourcefn clone(&self) -> Extensions
fn clone(&self) -> Extensions
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Extensions
impl Debug for Extensions
sourceimpl Default for Extensions
impl Default for Extensions
sourcefn default() -> Extensions
fn default() -> Extensions
Returns the “default value” for a type. Read more
sourceimpl 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.
sourceimpl Hash for Extensions
impl Hash for Extensions
sourceimpl PartialEq<Extensions> for Extensions
impl PartialEq<Extensions> for Extensions
sourcefn eq(&self, other: &Extensions) -> bool
fn eq(&self, other: &Extensions) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Extensions) -> bool
fn ne(&self, other: &Extensions) -> bool
This method tests for !=
.
sourceimpl Writeable for Extensions
impl Writeable for Extensions
sourcefn write_to<W>(&self, sink: &mut W) -> Result<(), Error> where
W: Write + ?Sized,
fn write_to<W>(&self, sink: &mut W) -> Result<(), Error> where
W: Write + ?Sized,
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. Read more
sourcefn 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
sourcefn 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. Read more
sourcefn 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 more
impl Eq for Extensions
impl StructuralEq for Extensions
impl StructuralPartialEq for Extensions
Auto Trait Implementations
impl RefUnwindSafe for Extensions
impl Send for Extensions
impl Sync for Extensions
impl Unpin for Extensions
impl UnwindSafe for Extensions
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Separable for T where
T: Display,
impl<T> Separable for T where
T: Display,
sourcefn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
Adds separators according to the given SeparatorPolicy
. Read more
sourcefn separate_with_commas(&self) -> String
fn separate_with_commas(&self) -> String
Inserts a comma every three digits from the right. Read more
sourcefn separate_with_spaces(&self) -> String
fn separate_with_spaces(&self) -> String
Inserts a space every three digits from the right. Read more
sourcefn separate_with_dots(&self) -> String
fn separate_with_dots(&self) -> String
Inserts a period every three digits from the right. Read more
sourcefn separate_with_underscores(&self) -> String
fn separate_with_underscores(&self) -> String
Inserts an underscore every three digits from the right. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more