Repository: actix/actix-net (language: rust)

Issue:
rework unnecessary bounds in capture_match_info_fn
I think these unnecessary bounds should be relaxed and `user_data` removed
```rust
pub fn capture_match_info_fn<R, T, F>(&self, res: &mut R, check: F)
where
    ...
    F: FnOnce(&R) -> bool
```

_Originally posted by @aliemjay in https://github.com/actix/actix-net/pull/373#discussion_r672635432_


Discussion / hints:
Feels like a pretty good signature actually once you look at how the router works and is [set up in Scope](https://github.com/actix/actix-web/blob/master/src/scope.rs#L533).

Still fine if you want to give it a go but would suggest trying out the actix-web integration in the process.

Fix patch:
diff --git a/actix-router/src/resource.rs b/actix-router/src/resource.rs
index 58016bb33d..eb0483a5cf 100644
--- a/actix-router/src/resource.rs
+++ b/actix-router/src/resource.rs
@@ -616,13 +616,8 @@ impl ResourceDef {
         profile_method!(find_match);
 
         match &self.pat_type {
-            PatternType::Static(segment) => {
-                if segment == path {
-                    Some(segment.len())
-                } else {
-                    None
-                }
-            }
+            PatternType::Static(segment) if path == segment => Some(segment.len()),
+            PatternType::Static(_) => None,
 
             PatternType::Prefix(prefix) if path == prefix => Some(prefix.len()),
             PatternType::Prefix(prefix) if is_strict_prefix(prefix, path) => Some(prefix.len()),
@@ -660,7 +655,7 @@ impl ResourceDef {
     /// ```
     pub fn capture_match_info<T: ResourcePath>(&self, path: &mut Path<T>) -> bool {
         profile_method!(is_path_match);
-        self.capture_match_info_fn(path, &|_, _| true, &None::<()>)
+        self.capture_match_info_fn(path, |_, _| true, ())
     }
 
     /// Collects dynamic segment values into `resource` after matching paths and executing
@@ -683,7 +678,7 @@ impl ResourceDef {
     ///     resource.capture_match_info_fn(
     ///         path,
     ///         // when env var is not set, reject when path contains "admin"
-    ///         &|res, admin_allowed| !res.path().contains("admin"),
+    ///         |res, admin_allowed| !res.path().contains("admin"),
     ///         &admin_allowed
     ///     )
     /// }
@@ -704,13 +699,13 @@ impl ResourceDef {
     pub fn capture_match_info_fn<R, T, F, U>(
         &self,
         resource: &mut R,
-        check_fn: &F,
-        user_data: &Option<U>,
+        check_fn: F,
+        user_data: U,
     ) -> bool
     where
         R: Resource<T>,
         T: ResourcePath,
-        F: Fn(&R, &Option<U>) -> bool,
+        F: FnOnce(&R, U) -> bool,
     {
         profile_method!(is_path_match_fn);
 


Test patch: