pub struct WeightedList<'a> { /* private fields */ }Expand description
The members of a validated weighted list.
§Examples
use parse_net::{negotiate::parse_weighted, Limits};
let w = parse_weighted(b"utf-8, iso-8859-1;q=0.5", &Limits::DEFAULT)?;
assert_eq!(w.len(), 2);
assert!(w.iter().all(|m| m.weight.thousandths() >= 500));Implementations§
Source§impl<'a> WeightedList<'a>
impl<'a> WeightedList<'a>
Sourcepub fn iter(&self) -> impl Iterator<Item = Weighted<'a>> + '_
pub fn iter(&self) -> impl Iterator<Item = Weighted<'a>> + '_
The members, in order.
§Examples
use parse_net::{negotiate::parse_weighted, Limits};
let w = parse_weighted(b"gzip;q=0.5, br", &Limits::DEFAULT)?;
let best = w.iter().max_by_key(|m| m.weight).map(|m| m.value);
assert_eq!(best, Some(&b"br"[..]));Trait Implementations§
Source§impl<'a> Clone for WeightedList<'a>
impl<'a> Clone for WeightedList<'a>
impl<'a> Copy for WeightedList<'a>
Auto Trait Implementations§
impl<'a> Freeze for WeightedList<'a>
impl<'a> RefUnwindSafe for WeightedList<'a>
impl<'a> Send for WeightedList<'a>
impl<'a> Sync for WeightedList<'a>
impl<'a> Unpin for WeightedList<'a>
impl<'a> UnsafeUnpin for WeightedList<'a>
impl<'a> UnwindSafe for WeightedList<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more