add_language

Macro add_language 

Source
macro_rules! add_language {
    ( $map: expr, $tag: expr, $label: expr ) => { ... };
}
Expand description

Given $map (a LanguageMap dictionary) insert $label keyed by $tag creating the collection in the process if it was None.

Raise LanguageTag error if the tag is invalid.

Example

let mut greetings = None;
let en = MyLanguageTag::from_str("en")?;
add_language!(greetings, &en, "Hello");

assert_eq!(greetings.unwrap().get(&en).unwrap(), "Hello");