diff --git a/src/recognizer.rs b/src/recognizer.rs index b95013759..6c01141c3 100644 --- a/src/recognizer.rs +++ b/src/recognizer.rs @@ -123,6 +123,9 @@ fn parse(pattern: &str) -> String { re } +/// Route match information +/// +/// If resource path contains variable patterns, `Params` stores this variables. #[derive(Debug)] pub struct Params { text: String, @@ -158,6 +161,7 @@ impl Params { .and_then(|m| m.map(|(start, end)| &self.text[start..end])) } + /// Get matched parameter by name pub fn get(&self, key: &str) -> Option<&str> { self.names.get(key).and_then(|&i| self.by_idx(i - 1)) } diff --git a/src/router.rs b/src/router.rs index 44d6202f4..eb1cd38d1 100644 --- a/src/router.rs +++ b/src/router.rs @@ -52,7 +52,7 @@ impl Router { /// A variable part is specified in the form `{identifier}`, where /// the identifier can be used later in a request handler to access the matched /// value for that part. This is done by looking up the identifier -/// in the Params object returned by `Request.match_info()` method. +/// in the `Params` object returned by `Request.match_info()` method. /// /// By default, each part matches the regular expression `[^{}/]+`. ///