From cd9b4628b10be7f0599815a5dc03c756a7fdc63e Mon Sep 17 00:00:00 2001 From: Jacob Rothstein Date: Tue, 10 Aug 2021 12:51:56 -0700 Subject: [PATCH] add key and value 'static lifetimes to captures --- src/request.rs | 8 ++++++-- src/router.rs | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/request.rs b/src/request.rs index e6b46762..854154e6 100644 --- a/src/request.rs +++ b/src/request.rs @@ -27,13 +27,17 @@ pin_project_lite::pin_project! { pub(crate) state: State, #[pin] pub(crate) req: http::Request, - pub(crate) route_params: Vec, + pub(crate) route_params: Vec>, } } impl Request { /// Create a new `Request`. - pub(crate) fn new(state: State, req: http_types::Request, route_params: Vec) -> Self { + pub(crate) fn new( + state: State, + req: http_types::Request, + route_params: Vec>, + ) -> Self { Self { state, req, diff --git a/src/router.rs b/src/router.rs index d80cc6b4..70b1ab35 100644 --- a/src/router.rs +++ b/src/router.rs @@ -26,7 +26,7 @@ impl std::fmt::Debug for Router { /// The result of routing a URL pub(crate) struct Selection<'a, State> { pub(crate) endpoint: &'a DynEndpoint, - pub(crate) params: Captures, + pub(crate) params: Captures<'static, 'static>, } impl Router { @@ -62,12 +62,12 @@ impl Router { { Selection { endpoint: m.handler(), - params: m.captures(), + params: m.captures().into_owned(), } } else if let Some(m) = self.all_method_router.best_match(path) { Selection { endpoint: m.handler(), - params: m.captures(), + params: m.captures().into_owned(), } } else if method == http_types::Method::Head { // If it is a HTTP HEAD request then check if there is a callback in the endpoints map