[][src]Struct matchit::Node

pub struct Node<V> { /* fields omitted */ }

A node in radix tree ordered by priority.

Priority is just the number of values registered in sub nodes (children, grandchildren, and so on..).

Implementations

impl<V> Node<V>[src]

pub fn insert(&mut self, path: &str, value: V)[src]

Insert a Node with the given value to the path.

pub fn match_path(&self, path: &str) -> Result<Match<'_, V>, bool>[src]

Returns the value registered with the given path. If no value can be found, an Err(bool) is returned which represents a TSR (trailing slash redirect) recommendation.


let mut matcher = Node::default();
matcher.insert("/home", "Welcome!");

if let Err(matched) = matcher.match_path("/home/") {
    assert_eq!(matched, true);
}

pub fn find_case_insensitive_path(
    &self,
    path: &str,
    fix_trailing_slash: bool
) -> Option<String>
[src]

Makes a case-insensitive match of the given path and tries to find a handler. It can optionally also fix trailing slashes. It returns the case-corrected path and a bool indicating whether the match was successful.


let mut matcher = Node::default();
matcher.insert("/home", "Welcome!");

let path = matcher.find_case_insensitive_path("/HoMe/", true).unwrap();
assert_eq!(path, "/home");

Trait Implementations

impl<V> Default for Node<V>[src]

Auto Trait Implementations

impl<V> RefUnwindSafe for Node<V> where
    V: RefUnwindSafe
[src]

impl<V> Send for Node<V> where
    V: Send
[src]

impl<V> Sync for Node<V> where
    V: Sync
[src]

impl<V> Unpin for Node<V> where
    V: Unpin
[src]

impl<V> UnwindSafe for Node<V> where
    V: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.