Module icu_locid::extensions::transform

source ·
Expand description

Transform Extensions provide information on content transformations in a given locale.

The main struct for this extension is Transform which contains Fields and an optional LanguageIdentifier.

§Examples

use icu::locid::extensions::transform::{Fields, Key, Transform, Value};
use icu::locid::{LanguageIdentifier, Locale};

let mut loc: Locale =
    "en-US-t-es-ar-h0-hybrid".parse().expect("Parsing failed.");

let lang: LanguageIdentifier =
    "es-AR".parse().expect("Parsing LanguageIdentifier failed.");

let key: Key = "h0".parse().expect("Parsing key failed.");
let value: Value = "hybrid".parse().expect("Parsing value failed.");

assert_eq!(loc.extensions.transform.lang, Some(lang));
assert!(loc.extensions.transform.fields.contains_key(&key));
assert_eq!(loc.extensions.transform.fields.get(&key), Some(&value));

assert_eq!(&loc.extensions.transform.to_string(), "t-es-ar-h0-hybrid");

Macros§

  • A macro allowing for compile-time construction of valid Key subtags.

Structs§