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>
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>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
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 more
impl<'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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more