pub struct Params<'k, 'v> { /* private fields */ }
Expand description
A list of parameters returned by a route match.
let matched = router.at("/users/1")?;
// you can iterate through the keys and values
for (key, value) in matched.params.iter() {
println!("key: {}, value: {}", key, value);
}
// or get a specific value by key
let id = matched.params.get("id");
assert_eq!(id, Some("1"));
Implementations
sourceimpl<'k, 'v> Params<'k, 'v>
impl<'k, 'v> Params<'k, 'v>
sourcepub fn get(&self, key: impl AsRef<str>) -> Option<&'v str>
pub fn get(&self, key: impl AsRef<str>) -> Option<&'v str>
Returns the value of the first parameter registered under the given key.
sourcepub fn iter(&self) -> ParamsIter<'_, 'k, 'v>ⓘNotable traits for ParamsIter<'ps, 'k, 'v>impl<'ps, 'k, 'v> Iterator for ParamsIter<'ps, 'k, 'v> type Item = (&'k str, &'v str);
pub fn iter(&self) -> ParamsIter<'_, 'k, 'v>ⓘNotable traits for ParamsIter<'ps, 'k, 'v>impl<'ps, 'k, 'v> Iterator for ParamsIter<'ps, 'k, 'v> type Item = (&'k str, &'v str);
Returns an iterator over the parameters in the list.
Trait Implementations
sourceimpl<'k, 'v> Ord for Params<'k, 'v>
impl<'k, 'v> Ord for Params<'k, 'v>
1.21.0 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<'k, 'v> PartialEq<Params<'k, 'v>> for Params<'k, 'v>
impl<'k, 'v> PartialEq<Params<'k, 'v>> for Params<'k, 'v>
sourceimpl<'k, 'v> PartialOrd<Params<'k, 'v>> for Params<'k, 'v>
impl<'k, 'v> PartialOrd<Params<'k, 'v>> for Params<'k, 'v>
sourcefn partial_cmp(&self, other: &Params<'k, 'v>) -> Option<Ordering>
fn partial_cmp(&self, other: &Params<'k, 'v>) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<'k, 'v> Eq for Params<'k, 'v>
impl<'k, 'v> StructuralEq for Params<'k, 'v>
impl<'k, 'v> StructuralPartialEq for Params<'k, 'v>
Auto Trait Implementations
impl<'k, 'v> RefUnwindSafe for Params<'k, 'v>
impl<'k, 'v> Send for Params<'k, 'v>
impl<'k, 'v> Sync for Params<'k, 'v>
impl<'k, 'v> Unpin for Params<'k, 'v>
impl<'k, 'v> UnwindSafe for Params<'k, 'v>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more