diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/makefile/inference_rules.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/makefile/inference_rules.rs b/src/makefile/inference_rules.rs index 7f77bd7..f841797 100644 --- a/src/makefile/inference_rules.rs +++ b/src/makefile/inference_rules.rs @@ -36,10 +36,10 @@ impl InferenceRule { pub fn first_match<'s, 't: 's>(&'s self, target_name: &'t str) -> Result<Option<Captures<'t>>> { self.products .iter() - .map(|pattern| { - // TODO find a better way to make the self_subdir_match test pass - r#match(pattern.strip_prefix("./").unwrap_or(pattern), target_name) - }) + // TODO find a better way to make the self_subdir_match test pass + .flat_map(|pattern| [pattern.strip_prefix("./"), Some(pattern.as_str())]) + .filter_map(|x| x) + .map(|pattern| r#match(pattern, target_name)) .try_fold(None, |x, y| y.map(|y| x.or(y))) } @@ -225,6 +225,7 @@ mod test { macros: MacroSet::new(), }; assert!(rule.matches("foo.o")?); + assert!(rule.matches("./foo.o")?); Ok(()) } } |