diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs --- a/rust/hg-core/src/matchers.rs +++ b/rust/hg-core/src/matchers.rs @@ -22,6 +22,7 @@ PatternSyntax, }; +use crate::dirstate::status::IgnoreFnType; use crate::filepatterns::normalize_path_bytes; use std::borrow::ToOwned; use std::collections::HashSet; @@ -246,7 +247,7 @@ /// ``` pub struct IncludeMatcher<'a> { patterns: Vec, - match_fn: Box Fn(&'r HgPath) -> bool + 'a + Sync>, + match_fn: IgnoreFnType<'a>, /// Whether all the patterns match a prefix (i.e. recursively) prefix: bool, roots: HashSet, @@ -341,9 +342,9 @@ /// Returns the regex pattern and a function that matches an `HgPath` against /// said regex formed by the given ignore patterns. -fn build_regex_match( - ignore_patterns: &[IgnorePattern], -) -> PatternResult<(Vec, Box bool + Sync>)> { +fn build_regex_match<'a, 'b>( + ignore_patterns: &'a [IgnorePattern], +) -> PatternResult<(Vec, IgnoreFnType<'b>)> { let mut regexps = vec![]; let mut exact_set = HashSet::new(); @@ -365,10 +366,10 @@ let func = move |filename: &HgPath| { exact_set.contains(filename) || matcher(filename) }; - Box::new(func) as Box bool + Sync> + Box::new(func) as IgnoreFnType } else { let func = move |filename: &HgPath| exact_set.contains(filename); - Box::new(func) as Box bool + Sync> + Box::new(func) as IgnoreFnType }; Ok((full_regex, func)) @@ -476,8 +477,8 @@ /// should be matched. fn build_match<'a, 'b>( ignore_patterns: Vec, -) -> PatternResult<(Vec, Box bool + 'b + Sync>)> { - let mut match_funcs: Vec bool + Sync>> = vec![]; +) -> PatternResult<(Vec, IgnoreFnType<'b>)> { + let mut match_funcs: Vec> = vec![]; // For debugging and printing let mut patterns = vec![]; @@ -564,10 +565,7 @@ mut all_pattern_files: Vec, root_dir: &Path, inspect_pattern_bytes: &mut impl FnMut(&[u8]), -) -> PatternResult<( - Box Fn(&'r HgPath) -> bool + Sync + 'a>, - Vec, -)> { +) -> PatternResult<(IgnoreFnType<'a>, Vec)> { let mut all_patterns = vec![]; let mut all_warnings = vec![];