Skip to content

Commit

Permalink
add key and value 'static lifetimes to captures
Browse files Browse the repository at this point in the history
  • Loading branch information
jbr committed Aug 10, 2021
1 parent e5d1ba9 commit cd9b462
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ pin_project_lite::pin_project! {
pub(crate) state: State,
#[pin]
pub(crate) req: http::Request,
pub(crate) route_params: Vec<Captures>,
pub(crate) route_params: Vec<Captures<'static, 'static>>,
}
}

impl<State> Request<State> {
/// Create a new `Request`.
pub(crate) fn new(state: State, req: http_types::Request, route_params: Vec<Captures>) -> Self {
pub(crate) fn new(
state: State,
req: http_types::Request,
route_params: Vec<Captures<'static, 'static>>,
) -> Self {
Self {
state,
req,
Expand Down
6 changes: 3 additions & 3 deletions src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl<State> std::fmt::Debug for Router<State> {
/// The result of routing a URL
pub(crate) struct Selection<'a, State> {
pub(crate) endpoint: &'a DynEndpoint<State>,
pub(crate) params: Captures,
pub(crate) params: Captures<'static, 'static>,
}

impl<State: Clone + Send + Sync + 'static> Router<State> {
Expand Down Expand Up @@ -62,12 +62,12 @@ impl<State: Clone + Send + Sync + 'static> Router<State> {
{
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
Expand Down

0 comments on commit cd9b462

Please sign in to comment.