From c642441492feb8e9d7bbcc45c6507540cfc6738f Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Wed, 18 Dec 2024 23:43:54 -0700 Subject: let ./egg% match ./eggbug and not just eggbug --- src/makefile/inference_rules.rs | 9 +++++---- 1 file 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>> { 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(()) } } -- cgit v1.2.3