macro_rules! locale {
($locale:literal) => { ... };
}
Expand description
A macro allowing for compile-time construction of valid Locale
s.
The macro will perform syntax canonicalization of the tag.
Examples
use icu::locid::{Locale, locale};
const DE_AT: Locale = locale!("de_at");
let de_at: Locale = "de_at".parse().unwrap();
assert_eq!(DE_AT, "de-AT");
assert_eq!(DE_AT, de_at);
Note: The macro cannot produce locales with variants or Unicode extensions due to
const limitations (see Heap Allocations in Constants
):
ⓘ
icu::locid::locale!("en-US-u-ca-ja");
Use runtime parsing instead:
"en-US-u-ca-ja".parse::<icu::locid::Locale>().unwrap();