pub struct PathPattern { /* private fields */ }Expand description
A compiled route path pattern (/users/:id) — a sequence of static and
:param [Segment]s. Matched against a run of Location segments by
match_prefix; the router composes
nested patterns by matching parent then child against successive segment runs.
Implementations§
Source§impl PathPattern
impl PathPattern
Sourcepub fn parse(pattern: &str) -> PathPattern
pub fn parse(pattern: &str) -> PathPattern
Compile a pattern string into segments (trailing/leading slashes ignored).
A :name segment is a parameter capture; everything else is static.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether this pattern is empty (an index/root pattern that consumes no
segments — e.g. a / route or a path-less shell route).
Sourcepub fn match_prefix(&self, segs: &[String]) -> Option<(usize, RouteParams)>
pub fn match_prefix(&self, segs: &[String]) -> Option<(usize, RouteParams)>
Try to match this pattern as a prefix of segs, capturing every
:param. Returns (consumed, params) — the number of leading segments
consumed (always self.len()) and the captured params — or None if a
static segment mismatches or there are too few segments to cover the
pattern.
Prefix (not whole-slice) matching is what lets nested routes compose: a parent consumes its segments, then the router feeds the remainder to the child.
Trait Implementations§
Source§impl Clone for PathPattern
impl Clone for PathPattern
Source§impl Debug for PathPattern
impl Debug for PathPattern
impl Eq for PathPattern
Source§impl PartialEq for PathPattern
impl PartialEq for PathPattern
impl StructuralPartialEq for PathPattern
Auto Trait Implementations§
impl Freeze for PathPattern
impl RefUnwindSafe for PathPattern
impl Send for PathPattern
impl Sync for PathPattern
impl Unpin for PathPattern
impl UnsafeUnpin for PathPattern
impl UnwindSafe for PathPattern
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.