@@ -259,36 +259,27 @@ pub struct HotSnapshot {
259259}
260260
261261/// Lookup a WebSocket route in a precomputed [`CompiledRouters`] (lock-free).
262- pub fn match_ws_route_compiled (
263- compiled : & CompiledRouters ,
264- path : & str ,
265- ) -> Option < ( usize , Vec < ( String , String ) > ) > {
266- compiled. websocket . at ( path) . ok ( ) . map ( |m| {
267- let mut pmap = Vec :: new ( ) ;
268- for ( k, v) in m. params . iter ( ) {
269- pmap. push ( ( k. to_string ( ) , v. to_string ( ) ) ) ;
270- }
271- ( * m. value , pmap)
272- } )
262+ pub fn match_ws_route_compiled < ' a , ' b > (
263+ compiled : & ' a CompiledRouters ,
264+ path : & ' b str ,
265+ ) -> Option < ( usize , matchit:: Params < ' a , ' b > ) > {
266+ compiled
267+ . websocket
268+ . at ( path)
269+ . ok ( )
270+ . map ( |m| ( * m. value , m. params ) )
273271}
274272
275273/// Lookup an HTTP route in a precomputed [`CompiledRouters`] (lock-free).
276274///
277275/// Returns ``None`` for unsupported method, ``Some(None)`` for no match, ``Some(Some(...))`` on hit.
278- #[ allow( clippy:: type_complexity) ]
279- pub fn match_route_compiled (
280- compiled : & CompiledRouters ,
276+ pub fn match_route_compiled < ' a , ' b > (
277+ compiled : & ' a CompiledRouters ,
281278 method : & str ,
282- path : & str ,
283- ) -> Option < Option < ( usize , Vec < ( String , String ) > ) > > {
279+ path : & ' b str ,
280+ ) -> Option < Option < ( usize , matchit :: Params < ' a , ' b > ) > > {
284281 let g = router_for_compiled ( compiled, method) ?;
285- Some ( g. at ( path) . ok ( ) . map ( |m| {
286- let mut pmap = Vec :: new ( ) ;
287- for ( k, v) in m. params . iter ( ) {
288- pmap. push ( ( k. to_string ( ) , v. to_string ( ) ) ) ;
289- }
290- ( * m. value , pmap)
291- } ) )
282+ Some ( g. at ( path) . ok ( ) . map ( |m| ( * m. value , m. params ) ) )
292283}
293284
294285/// All HTTP methods that match `path` in a precomputed [`CompiledRouters`] (lock-free 405 list).
@@ -368,7 +359,14 @@ fn match_route(
368359 path : & str ,
369360) -> Option < Option < ( usize , Vec < ( String , String ) > ) > > {
370361 if let Some ( c) = & state. compiled {
371- return match_route_compiled ( c, method, path) ;
362+ let res = match_route_compiled ( c, method, path) ?;
363+ return Some ( res. map ( |( idx, params) | {
364+ let mut pmap = Vec :: new ( ) ;
365+ for ( k, v) in params. iter ( ) {
366+ pmap. push ( ( k. to_string ( ) , v. to_string ( ) ) ) ;
367+ }
368+ ( idx, pmap)
369+ } ) ) ;
372370 }
373371 let g = map_method_router ( state, method) ?;
374372 Some ( g. at ( path) . ok ( ) . map ( |m| {
0 commit comments