Struct Transform

struct Transform { ... }

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

impl Transform

fn to_string(self: &Self) -> String

Converts the given value to a String.

Under the hood, this uses an efficient Writeable implementation. However, in order to avoid allocating a string, it is more efficient to use Writeable directly.

impl Transform

const fn new() -> Self

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

Examples

use icu::locale::extensions::transform::Transform;

assert_eq!(Transform::new(), Transform::default());
fn is_empty(self: &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());
fn clear(self: &mut Self)

Clears the transform extension, effectively removing it from the locale.

Examples

use icu::locale::Locale;

let mut loc: Locale = "en-US-t-es-ar".parse().unwrap();
loc.extensions.transform.clear();
assert_eq!(loc, "en-US".parse().unwrap());
fn total_cmp(self: &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.

impl Clone for Transform

fn clone(self: &Self) -> Transform

impl Debug for Transform

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Default for Transform

fn default() -> Transform

impl Display for Transform

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Eq for Transform

impl Freeze for Transform

impl Hash for Transform

fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)

impl PartialEq for Transform

fn eq(self: &Self, other: &Transform) -> bool

impl RefUnwindSafe for Transform

impl Send for Transform

impl StructuralPartialEq for Transform

impl Sync for Transform

impl Unpin for Transform

impl UnsafeUnpin for Transform

impl UnwindSafe for Transform

impl Writeable for Transform

fn write_to<W: core::fmt::Write + ?Sized>(self: &Self, sink: &mut W) -> Result
fn writeable_length_hint(self: &Self) -> LengthHint

impl<T> Any for Transform

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Transform

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Transform

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Transform

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> ErasedDestructor for Transform

impl<T> From for Transform

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Transform

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for Transform

fn to_string(self: &Self) -> String

impl<T, U> Into for Transform

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for Transform

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Transform

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>