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::locale::extensions::transform::{Key, Value};
use icu::locale::{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 try_from_str(s: &str) -> Result<Transform, ParseError>
pub fn try_from_str(s: &str) -> Result<Transform, ParseError>
A constructor which takes a str slice, parses it and
produces a well-formed Transform
.
sourcepub fn try_from_utf8(code_units: &[u8]) -> Result<Transform, ParseError>
pub fn try_from_utf8(code_units: &[u8]) -> Result<Transform, ParseError>
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::locale::Locale;
let mut loc: Locale = "en-US-t-es-ar".parse().expect("Parsing failed.");
assert!(!loc.extensions.transform.is_empty());
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 Writeable for Transform
impl Writeable for Transform
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 Transform
impl StructuralPartialEq for Transform
Auto Trait Implementations§
impl Freeze for Transform
impl RefUnwindSafe for Transform
impl Send for Transform
impl Sync for Transform
impl Unpin for Transform
impl UnwindSafe for Transform
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