Skip to content

Commit

Permalink
Add Changes::filter_by_project_path
Browse files Browse the repository at this point in the history
Summary: Useful for future work.

Reviewed By: aniketmathur

Differential Revision: D57542273

fbshipit-source-id: 658a4e03846a2bdf3e4a419d40daa725d7b0cd72
  • Loading branch information
ndmitchell authored and facebook-github-bot committed May 28, 2024
1 parent 4126a5e commit 4426334
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions btd/src/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@ impl Changes {
self.contains_cell_path(&package.as_cell_path())
}

pub fn filter_by_extension(&self, f: impl Fn(Option<&str>) -> bool) -> Changes {
pub fn filter_by_cell_path(&self, f: impl Fn(&CellPath) -> bool) -> Changes {
let paths = self
.paths
.iter()
.filter(|x| f(x.get().0.extension()))
.filter(|x| f(&x.get().0))
.cloned()
.collect();
Self::from_paths(paths)
}

pub fn filter_by_extension(&self, f: impl Fn(Option<&str>) -> bool) -> Changes {
self.filter_by_cell_path(|x| f(x.extension()))
}
}

0 comments on commit 4426334

Please sign in to comment.