Struct icu_locid::extensions::transform::Transform
source · pub struct Transform {
pub lang: Option<LanguageIdentifier>,
pub fields: Fields,
}
Expand description
A list of Unicode BCP47 T Extensions
as defined in Unicode Locale Identifier
specification.
Transform extension carries information about source language or script of
transformed content, including content that has been transliterated, transcribed,
or translated, or in some other way influenced by the source (See RFC 6497
for details).
§Examples
use icu::locid::extensions::transform::{Key, Value};
use icu::locid::{LanguageIdentifier, Locale};
let mut loc: Locale =
"de-t-en-us-h0-hybrid".parse().expect("Parsing failed.");
let en_us: LanguageIdentifier = "en-US".parse().expect("Parsing failed.");
assert_eq!(loc.extensions.transform.lang, Some(en_us));
let key: Key = "h0".parse().expect("Parsing key failed.");
let value: Value = "hybrid".parse().expect("Parsing value failed.");
assert_eq!(loc.extensions.transform.fields.get(&key), Some(&value));
Fields§
§lang: Option<LanguageIdentifier>
The LanguageIdentifier
specified with this locale extension, or None
if not present.
fields: Fields
The key-value pairs present in this locale extension, with each extension key subtag associated to its provided value subtag.
Implementations§
source§impl Transform
impl Transform
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if there are no tfields and no tlang in the TransformExtensionList
.
§Examples
use icu::locid::Locale;
let mut loc: Locale = "en-US-t-es-ar".parse().expect("Parsing failed.");
assert!(!loc.extensions.transform.is_empty());
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the transform extension, effectively removing it from the locale.
§Examples
use icu::locid::Locale;
let mut loc: Locale = "en-US-t-es-ar".parse().unwrap();
loc.extensions.transform.clear();
assert_eq!(loc, "en-US".parse().unwrap());
pub(crate) fn as_tuple( &self, ) -> (Option<(Language, Option<Script>, Option<Region>, &Variants)>, &Fields)
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.
pub(crate) fn try_from_iter( iter: &mut SubtagIterator<'_>, ) -> Result<Self, ParserError>
pub(crate) fn for_each_subtag_str<E, F>(&self, f: &mut F) -> Result<(), E>
Trait Implementations§
source§impl Display for Transform
impl Display for Transform
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
source§impl PartialEq for Transform
impl PartialEq for Transform
source§impl Writeable for Transform
impl Writeable for Transform
source§fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
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.