pub fn negotiate<L: Locale>(accept_language: &str) -> LExpand description
The locale of L that best matches an Accept-Language header value, or the default.
The ranges in accept_language are tried from the highest q to the
lowest, and in the order written where two are equal. A range matches a
locale whose tag is the same, ignoring case, or the same after the last
-subtag of the range is removed one at a time, so ja-JP matches ja.
A locale whose tag starts with the range and a - matches too, so en
matches en-US. *, a header with no match, and an empty header give
the first locale of Locale::ALL.
assert_eq!(negotiate::<Lang>("ja-JP,ja;q=0.9,en;q=0.8"), Lang::Ja);
assert_eq!(negotiate::<Lang>("fr, en;q=0.5"), Lang::En);
assert_eq!(negotiate::<Lang>("fr"), Lang::En);ยงPanics
Panics if Locale::ALL is empty.