compare_changes/lib.rs
1mod matcher;
2mod path;
3
4pub fn path_matches(path: &str, files: &[&str]) -> Option<usize> {
5 if files.is_empty() {
6 return None;
7 }
8
9 // Parse the single path
10 let parsed_path = path::parse(path);
11
12 // If the path is negated, immediately return None
13 if matches!(parsed_path.segments.first(), Some(path::Segment::Negation)) {
14 return None;
15 }
16
17 // Check if any file matches the path
18 files
19 .iter()
20 .enumerate()
21 .find(|(_, file)| matcher::match_path(&parsed_path.segments, file))
22 .map(|(i, _)| i)
23}