Macro icu_locid_macros::langid[][src]

langid!() { /* proc-macro */ }

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

The macro will perform syntax canonicalization of the tag.

Examples

use icu::locid::LanguageIdentifier;
use icu::locid::macros::langid;

const DE_AT: LanguageIdentifier = langid!("de_at");

let de_at: LanguageIdentifier = "de_at".parse()
    .expect("Failed to parse language identifier.");

assert_eq!(DE_AT, "de-AT");
assert_eq!(DE_AT, de_at);

Note: As of Rust 1.47, the macro cannot produce language identifier with variants in the const mode pending Heap Allocations in Constants.