@@ -190,7 +190,11 @@ impl<'a, D: 'a> Router<'a, D> {
190
190
191
191
/// Register an HTTP handler that will exclusively respond to HEAD requests. Enables the use of
192
192
/// `async/await` syntax in the callback.
193
- pub fn head_async < T > ( mut self , pattern : & str , func : fn ( Request , RouteContext < D > ) -> T ) -> Self
193
+ pub fn head_async < T > (
194
+ mut self ,
195
+ pattern : & str ,
196
+ func : impl Fn ( Request , RouteContext < D > ) -> T + ' a ,
197
+ ) -> Self
194
198
where
195
199
T : Future < Output = Result < Response > > + ' a ,
196
200
{
@@ -204,7 +208,11 @@ impl<'a, D: 'a> Router<'a, D> {
204
208
205
209
/// Register an HTTP handler that will exclusively respond to GET requests. Enables the use of
206
210
/// `async/await` syntax in the callback.
207
- pub fn get_async < T > ( mut self , pattern : & str , func : fn ( Request , RouteContext < D > ) -> T ) -> Self
211
+ pub fn get_async < T > (
212
+ mut self ,
213
+ pattern : & str ,
214
+ func : impl Fn ( Request , RouteContext < D > ) -> T + ' a ,
215
+ ) -> Self
208
216
where
209
217
T : Future < Output = Result < Response > > + ' a ,
210
218
{
@@ -218,7 +226,11 @@ impl<'a, D: 'a> Router<'a, D> {
218
226
219
227
/// Register an HTTP handler that will exclusively respond to POST requests. Enables the use of
220
228
/// `async/await` syntax in the callback.
221
- pub fn post_async < T > ( mut self , pattern : & str , func : fn ( Request , RouteContext < D > ) -> T ) -> Self
229
+ pub fn post_async < T > (
230
+ mut self ,
231
+ pattern : & str ,
232
+ func : impl Fn ( Request , RouteContext < D > ) -> T + ' a ,
233
+ ) -> Self
222
234
where
223
235
T : Future < Output = Result < Response > > + ' a ,
224
236
{
@@ -232,7 +244,11 @@ impl<'a, D: 'a> Router<'a, D> {
232
244
233
245
/// Register an HTTP handler that will exclusively respond to PUT requests. Enables the use of
234
246
/// `async/await` syntax in the callback.
235
- pub fn put_async < T > ( mut self , pattern : & str , func : fn ( Request , RouteContext < D > ) -> T ) -> Self
247
+ pub fn put_async < T > (
248
+ mut self ,
249
+ pattern : & str ,
250
+ func : impl Fn ( Request , RouteContext < D > ) -> T + ' a ,
251
+ ) -> Self
236
252
where
237
253
T : Future < Output = Result < Response > > + ' a ,
238
254
{
@@ -246,7 +262,11 @@ impl<'a, D: 'a> Router<'a, D> {
246
262
247
263
/// Register an HTTP handler that will exclusively respond to PATCH requests. Enables the use of
248
264
/// `async/await` syntax in the callback.
249
- pub fn patch_async < T > ( mut self , pattern : & str , func : fn ( Request , RouteContext < D > ) -> T ) -> Self
265
+ pub fn patch_async < T > (
266
+ mut self ,
267
+ pattern : & str ,
268
+ func : impl Fn ( Request , RouteContext < D > ) -> T + ' a ,
269
+ ) -> Self
250
270
where
251
271
T : Future < Output = Result < Response > > + ' a ,
252
272
{
@@ -260,7 +280,11 @@ impl<'a, D: 'a> Router<'a, D> {
260
280
261
281
/// Register an HTTP handler that will exclusively respond to DELETE requests. Enables the use
262
282
/// of `async/await` syntax in the callback.
263
- pub fn delete_async < T > ( mut self , pattern : & str , func : fn ( Request , RouteContext < D > ) -> T ) -> Self
283
+ pub fn delete_async < T > (
284
+ mut self ,
285
+ pattern : & str ,
286
+ func : impl Fn ( Request , RouteContext < D > ) -> T + ' a ,
287
+ ) -> Self
264
288
where
265
289
T : Future < Output = Result < Response > > + ' a ,
266
290
{
@@ -277,7 +301,7 @@ impl<'a, D: 'a> Router<'a, D> {
277
301
pub fn options_async < T > (
278
302
mut self ,
279
303
pattern : & str ,
280
- func : fn ( Request , RouteContext < D > ) -> T ,
304
+ func : impl Fn ( Request , RouteContext < D > ) -> T + ' a ,
281
305
) -> Self
282
306
where
283
307
T : Future < Output = Result < Response > > + ' a ,
@@ -292,7 +316,11 @@ impl<'a, D: 'a> Router<'a, D> {
292
316
293
317
/// Register an HTTP handler that will respond to any requests. Enables the use of `async/await`
294
318
/// syntax in the callback.
295
- pub fn on_async < T > ( mut self , pattern : & str , func : fn ( Request , RouteContext < D > ) -> T ) -> Self
319
+ pub fn on_async < T > (
320
+ mut self ,
321
+ pattern : & str ,
322
+ func : impl Fn ( Request , RouteContext < D > ) -> T + ' a ,
323
+ ) -> Self
296
324
where
297
325
T : Future < Output = Result < Response > > + ' a ,
298
326
{
@@ -309,7 +337,7 @@ impl<'a, D: 'a> Router<'a, D> {
309
337
pub fn or_else_any_method_async < T > (
310
338
mut self ,
311
339
pattern : & str ,
312
- func : fn ( Request , RouteContext < D > ) -> T ,
340
+ func : impl Fn ( Request , RouteContext < D > ) -> T + ' a ,
313
341
) -> Self
314
342
where
315
343
T : Future < Output = Result < Response > > + ' a ,
0 commit comments