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