pub fn priority_header_preferred<'a, I>(
input: &'a str,
) -> Option<usize> where
I: Iterator<Item = &'a str>,
Returns the preferred value amongst a priority header.
This function takes the value of a priority header and a list of elements that can be handled by the server, and returns the index within that list of the element with the highest priority.
If multiple elements in
handled match and have the same priority, the first one is returned.
use rouille::input::priority_header_preferred; let header = "text/plain; q=1.2, image/png; q=2.0"; let handled = ["image/gif", "image/png", "text/plain"]; assert_eq!(priority_header_preferred(header, handled.iter().cloned()), Some(1));