Function accept_language::intersection_with_quality
source · pub fn intersection_with_quality(
raw_languages: &str,
supported_languages: &[&str]
) -> Vec<(String, f32)>
Expand description
Similar to intersection
but with the quality as f32
appended for each language.
This enables distinction between the default language of a user (value 1.0) and the
best match. If you don’t want to assign your users immediatly to a non-default choice and you plan to add
more languages later on in your webserver.
Example
use accept_language::intersection_with_quality;
let common_languages = intersection_with_quality("en-US, en-GB;q=0.5", &["en-US", "de", "en-GB"]);
assert_eq!(common_languages,vec![(String::from("en-US"), 1.0), (String::from("en-GB"), 0.5)])