#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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§

Returns a new empty map of extensions. Same as default(), but is const.

Examples
use icu::locid::extensions::Extensions;

assert_eq!(Extensions::new(), Extensions::default());

Function to create a new map of extensions containing exactly one unicode extension, callable in const context.

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());

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§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

This trait is implemented for compatibility with fmt!. To create a string, [Writeable::write_to_string] is usually more efficient.

Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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.
Returns a hint for the number of UTF-8 bytes that will be written to the sink. Read more
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.
Creates a new String with the data from this Writeable. Like ToString, but smaller and faster. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.