Function match_lang

Source
pub fn match_lang<L: Language>(
    available: impl IntoIterator<Item = L> + Clone,
    accept: &str,
) -> Option<L>
Expand description

Tries to match an available language to a single accepted language.

This function can be used to match a language from a single language tag, for example from a url.

Languages matching is case-insensitive.

use web_lang::match_lang;

assert_eq!(
    match_lang(
        ["en", "en-au", "de"],
        "en-gb"
    ),
    Some("en")
);