Macro icu::locid::langid

source ·
macro_rules! langid {
    ($langid:literal) => { ... };
}
Expand description

A macro allowing for compile-time construction of valid LanguageIdentifiers.

The macro will perform syntax canonicalization of the tag.

Examples

use icu::locid::{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::locid::langid!("und-variant1-variant2");

Use runtime parsing instead:

"und-variant1-variant2"
    .parse::<icu::locid::LanguageIdentifier>()
    .unwrap();