Skip to content

Commit 5379a46

Browse files
authored
ResourceDef: relax unnecessary bounds (#381)
1 parent f8f1ac9 commit 5379a46

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

actix-router/src/resource.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -616,13 +616,8 @@ impl ResourceDef {
616616
profile_method!(find_match);
617617

618618
match &self.pat_type {
619-
PatternType::Static(segment) => {
620-
if segment == path {
621-
Some(segment.len())
622-
} else {
623-
None
624-
}
625-
}
619+
PatternType::Static(segment) if path == segment => Some(segment.len()),
620+
PatternType::Static(_) => None,
626621

627622
PatternType::Prefix(prefix) if path == prefix => Some(prefix.len()),
628623
PatternType::Prefix(prefix) if is_strict_prefix(prefix, path) => Some(prefix.len()),
@@ -660,7 +655,7 @@ impl ResourceDef {
660655
/// ```
661656
pub fn capture_match_info<T: ResourcePath>(&self, path: &mut Path<T>) -> bool {
662657
profile_method!(is_path_match);
663-
self.capture_match_info_fn(path, &|_, _| true, &None::<()>)
658+
self.capture_match_info_fn(path, |_, _| true, ())
664659
}
665660

666661
/// Collects dynamic segment values into `resource` after matching paths and executing
@@ -683,7 +678,7 @@ impl ResourceDef {
683678
/// resource.capture_match_info_fn(
684679
/// path,
685680
/// // when env var is not set, reject when path contains "admin"
686-
/// &|res, admin_allowed| !res.path().contains("admin"),
681+
/// |res, admin_allowed| !res.path().contains("admin"),
687682
/// &admin_allowed
688683
/// )
689684
/// }
@@ -704,13 +699,13 @@ impl ResourceDef {
704699
pub fn capture_match_info_fn<R, T, F, U>(
705700
&self,
706701
resource: &mut R,
707-
check_fn: &F,
708-
user_data: &Option<U>,
702+
check_fn: F,
703+
user_data: U,
709704
) -> bool
710705
where
711706
R: Resource<T>,
712707
T: ResourcePath,
713-
F: Fn(&R, &Option<U>) -> bool,
708+
F: FnOnce(&R, U) -> bool,
714709
{
715710
profile_method!(is_path_match_fn);
716711

0 commit comments

Comments
 (0)