Macro icu_locale::langid
macro_rules! langid { ($langid:literal) => { ... }; }
Expand description
A macro allowing for compile-time construction of valid LanguageIdentifier
s.
The macro will perform syntax normalization of the tag.
§Examples
use icu::locale::{langid, LanguageIdentifier};
const DE_AT: LanguageIdentifier = langid!("de_at");
let de_at: LanguageIdentifier = "de_at".parse().unwrap();
assert_eq!(DE_AT, de_at);
Note: The macro cannot produce language identifiers with more than one variants due to const
limitations (see Heap Allocations in Constants
):
ⓘ
icu::locale::langid!("und-variant1-variant2");
Use runtime parsing instead:
"und-variant1-variant2"
.parse::<icu::locale::LanguageIdentifier>()
.unwrap();