diff options
author | Melody Horn <melody@boringcactus.com> | 2024-12-18 23:43:54 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2024-12-18 23:43:54 -0700 |
commit | c642441492feb8e9d7bbcc45c6507540cfc6738f (patch) | |
tree | 962295d7e0f5c740f717bdf2b11d72c801a24470 /src/makefile/inference_rules.rs | |
parent | ad2d35f273403469e64ca8ccc3d2ba594609fa30 (diff) | |
download | makers-c642441492feb8e9d7bbcc45c6507540cfc6738f.tar.gz makers-c642441492feb8e9d7bbcc45c6507540cfc6738f.zip |
Diffstat (limited to 'src/makefile/inference_rules.rs')
-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(()) } } |