##// END OF EJS Templates
rust-matchers: improve `Matcher` trait ergonomics...
Raphaël Gomès -
r44284:1bb4e9b0 default
parent child Browse files
Show More
@@ -10,21 +10,21
10 10 use crate::utils::hg_path::{HgPath, HgPathBuf};
11 11 use std::collections::HashSet;
12 12
13 pub enum VisitChildrenSet {
13 pub enum VisitChildrenSet<'a> {
14 14 /// Don't visit anything
15 15 Empty,
16 16 /// Only visit this directory
17 17 This,
18 18 /// Visit this directory and these subdirectories
19 19 /// TODO Should we implement a `NonEmptyHashSet`?
20 Set(HashSet<HgPathBuf>),
20 Set(HashSet<&'a HgPath>),
21 21 /// Visit this directory and all subdirectories
22 22 Recursive,
23 23 }
24 24
25 25 pub trait Matcher {
26 26 /// Explicitly listed files
27 fn file_set(&self) -> HashSet<&HgPath>;
27 fn file_set(&self) -> Option<&HashSet<&HgPath>>;
28 28 /// Returns whether `filename` is in `file_set`
29 29 fn exact_match(&self, filename: impl AsRef<HgPath>) -> bool;
30 30 /// Returns whether `filename` is matched by this matcher
@@ -82,8 +82,8 pub trait Matcher {
82 82 pub struct AlwaysMatcher;
83 83
84 84 impl Matcher for AlwaysMatcher {
85 fn file_set(&self) -> HashSet<&HgPath> {
86 HashSet::new()
85 fn file_set(&self) -> Option<&HashSet<&HgPath>> {
86 None
87 87 }
88 88 fn exact_match(&self, _filename: impl AsRef<HgPath>) -> bool {
89 89 false
General Comments 0
You need to be logged in to leave comments. Login now