Macro locale
macro_rules! locale {
($locale:literal) => { ... };
}
A macro allowing for compile-time construction of valid Locales.
The macro will perform syntax normalization of the tag.
Examples
use ;
const DE_AT: Locale = locale!;
let de_at: Locale = "de-at".parse.unwrap;
assert_eq!;
Note: The macro cannot produce locales with more than one variant or multiple extensions
(only single keyword unicode extension is supported) due to const
limitations (see Heap Allocations in Constants):
icu::locale::locale!("sl-IT-rozaj-biske-1994");
Use runtime parsing instead:
"sl-IT-rozaj-biske-1994"
.
.unwrap;
Locales with multiple keys are not supported
icu::locale::locale!("th-TH-u-ca-buddhist-nu-thai");
Use runtime parsing instead:
"th-TH-u-ca-buddhist-nu-thai"
.
.unwrap;
Locales with attributes are not supported
icu::locale::locale!("en-US-u-foobar-ca-buddhist");
Use runtime parsing instead:
"en-US-u-foobar-ca-buddhist"
.
.unwrap;
Locales with single key but multiple types are not supported
icu::locale::locale!("en-US-u-ca-islamic-umalqura");
Use runtime parsing instead:
"en-US-u-ca-islamic-umalqura"
.
.unwrap;