diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs index 2a169781556ee3deb819640208fe8c1e582b381d_cnVzdC9oZy1jb3JlL3NyYy9tYXRjaGVycy5ycw==..75f785888a7b7ab778fb05ba004597096f8e27d3_cnVzdC9oZy1jb3JlL3NyYy9tYXRjaGVycy5ycw== 100644 --- a/rust/hg-core/src/matchers.rs +++ b/rust/hg-core/src/matchers.rs @@ -49,5 +49,5 @@ /// Explicitly listed files fn file_set(&self) -> Option<&HashSet<&HgPath>>; /// Returns whether `filename` is in `file_set` - fn exact_match(&self, filename: impl AsRef<HgPath>) -> bool; + fn exact_match(&self, filename: &HgPath) -> bool; /// Returns whether `filename` is matched by this matcher @@ -53,5 +53,5 @@ /// Returns whether `filename` is matched by this matcher - fn matches(&self, filename: impl AsRef<HgPath>) -> bool; + fn matches(&self, filename: &HgPath) -> bool; /// Decides whether a directory should be visited based on whether it /// has potential matches in it or one of its subdirectories, and /// potentially lists which subdirectories of that directory should be @@ -89,10 +89,7 @@ /// no files in this dir to investigate (or equivalently that if there are /// files to investigate in 'dir' that it will always return /// `VisitChildrenSet::This`). - fn visit_children_set( - &self, - directory: impl AsRef<HgPath>, - ) -> VisitChildrenSet; + fn visit_children_set(&self, directory: &HgPath) -> VisitChildrenSet; /// Matcher will match everything and `files_set()` will be empty: /// optimization might be possible. fn matches_everything(&self) -> bool; @@ -119,6 +116,6 @@ fn file_set(&self) -> Option<&HashSet<&HgPath>> { None } - fn exact_match(&self, _filename: impl AsRef<HgPath>) -> bool { + fn exact_match(&self, _filename: &HgPath) -> bool { false } @@ -123,5 +120,5 @@ false } - fn matches(&self, _filename: impl AsRef<HgPath>) -> bool { + fn matches(&self, _filename: &HgPath) -> bool { true } @@ -126,9 +123,6 @@ true } - fn visit_children_set( - &self, - _directory: impl AsRef<HgPath>, - ) -> VisitChildrenSet { + fn visit_children_set(&self, _directory: &HgPath) -> VisitChildrenSet { VisitChildrenSet::Recursive } fn matches_everything(&self) -> bool { @@ -143,5 +137,5 @@ /// patterns. /// ///``` -/// use hg::{ matchers::{Matcher, FileMatcher}, utils::hg_path::HgPath }; +/// use hg::{ matchers::{Matcher, FileMatcher}, utils::hg_path::{HgPath, HgPathBuf} }; /// @@ -147,5 +141,5 @@ /// -/// let files = [HgPath::new(b"a.txt"), HgPath::new(br"re:.*\.c$")]; +/// let files = [HgPathBuf::from_bytes(b"a.txt"), HgPathBuf::from_bytes(br"re:.*\.c$")]; /// let matcher = FileMatcher::new(&files).unwrap(); /// /// assert_eq!(matcher.matches(HgPath::new(b"a.txt")), true); @@ -160,11 +154,9 @@ } impl<'a> FileMatcher<'a> { - pub fn new( - files: &'a [impl AsRef<HgPath>], - ) -> Result<Self, DirstateMapError> { + pub fn new(files: &'a [HgPathBuf]) -> Result<Self, DirstateMapError> { Ok(Self { files: HashSet::from_iter(files.iter().map(AsRef::as_ref)), dirs: DirsMultiset::from_manifest(files)?, }) } @@ -166,9 +158,9 @@ Ok(Self { files: HashSet::from_iter(files.iter().map(AsRef::as_ref)), dirs: DirsMultiset::from_manifest(files)?, }) } - fn inner_matches(&self, filename: impl AsRef<HgPath>) -> bool { + fn inner_matches(&self, filename: &HgPath) -> bool { self.files.contains(filename.as_ref()) } } @@ -177,6 +169,6 @@ fn file_set(&self) -> Option<&HashSet<&HgPath>> { Some(&self.files) } - fn exact_match(&self, filename: impl AsRef<HgPath>) -> bool { + fn exact_match(&self, filename: &HgPath) -> bool { self.inner_matches(filename) } @@ -181,5 +173,5 @@ self.inner_matches(filename) } - fn matches(&self, filename: impl AsRef<HgPath>) -> bool { + fn matches(&self, filename: &HgPath) -> bool { self.inner_matches(filename) } @@ -184,9 +176,6 @@ self.inner_matches(filename) } - fn visit_children_set( - &self, - directory: impl AsRef<HgPath>, - ) -> VisitChildrenSet { + fn visit_children_set(&self, directory: &HgPath) -> VisitChildrenSet { if self.files.is_empty() || !self.dirs.contains(&directory) { return VisitChildrenSet::Empty; } @@ -270,7 +259,7 @@ None } - fn exact_match(&self, _filename: impl AsRef<HgPath>) -> bool { + fn exact_match(&self, _filename: &HgPath) -> bool { false } @@ -274,7 +263,7 @@ false } - fn matches(&self, filename: impl AsRef<HgPath>) -> bool { + fn matches(&self, filename: &HgPath) -> bool { (self.match_fn)(filename.as_ref()) } @@ -278,10 +267,7 @@ (self.match_fn)(filename.as_ref()) } - fn visit_children_set( - &self, - directory: impl AsRef<HgPath>, - ) -> VisitChildrenSet { + fn visit_children_set(&self, directory: &HgPath) -> VisitChildrenSet { let dir = directory.as_ref(); if self.prefix && self.roots.contains(dir) { return VisitChildrenSet::Recursive; @@ -725,7 +711,7 @@ #[test] fn test_filematcher_visit_children_set() { // Visitchildrenset - let files = vec![HgPath::new(b"dir/subdir/foo.txt")]; + let files = vec![HgPathBuf::from_bytes(b"dir/subdir/foo.txt")]; let matcher = FileMatcher::new(&files).unwrap(); let mut set = HashSet::new(); @@ -766,7 +752,7 @@ #[test] fn test_filematcher_visit_children_set_files_and_dirs() { let files = vec![ - HgPath::new(b"rootfile.txt"), - HgPath::new(b"a/file1.txt"), - HgPath::new(b"a/b/file2.txt"), + HgPathBuf::from_bytes(b"rootfile.txt"), + HgPathBuf::from_bytes(b"a/file1.txt"), + HgPathBuf::from_bytes(b"a/b/file2.txt"), // No file in a/b/c @@ -772,5 +758,5 @@ // No file in a/b/c - HgPath::new(b"a/b/c/d/file4.txt"), + HgPathBuf::from_bytes(b"a/b/c/d/file4.txt"), ]; let matcher = FileMatcher::new(&files).unwrap();