# HG changeset patch # User Raphaël Gomès # Date 1573053864 -3600 # Node ID 27c25c0dc9672a62ea6ae7c41cbf63448143db57 # Parent 11db74349b248715cb49ad02803bfff289c6ba39 rust-matchers: remove default implementations for `Matcher` trait We don't expect a whole lot of matchers to be defined, and this makes it more obvious what a matcher does by reading its `impl Matcher for FooMatcher`. This patch has the added benefit of fixing the `AlwaysMatcher`, its `matches` function differs from the former default. Differential Revision: https://phab.mercurial-scm.org/D7255 diff -r 11db74349b24 -r 27c25c0dc967 rust/hg-core/src/matchers.rs --- a/rust/hg-core/src/matchers.rs Wed Oct 23 13:55:12 2019 -0700 +++ b/rust/hg-core/src/matchers.rs Wed Nov 06 16:24:24 2019 +0100 @@ -26,13 +26,9 @@ /// Explicitly listed files fn file_set(&self) -> HashSet<&HgPath>; /// Returns whether `filename` is in `file_set` - fn exact_match(&self, _filename: impl AsRef) -> bool { - false - } + fn exact_match(&self, filename: impl AsRef) -> bool; /// Returns whether `filename` is matched by this matcher - fn matches(&self, _filename: impl AsRef) -> bool { - false - } + fn matches(&self, filename: impl AsRef) -> 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 @@ -71,20 +67,14 @@ /// `VisitChildrenSet::This`). fn visit_children_set( &self, - _directory: impl AsRef, - ) -> VisitChildrenSet { - VisitChildrenSet::This - } + directory: impl AsRef, + ) -> VisitChildrenSet; /// Matcher will match everything and `files_set()` will be empty: /// optimization might be possible. - fn matches_everything(&self) -> bool { - false - } + fn matches_everything(&self) -> bool; /// Matcher will match exactly the files in `files_set()`: optimization /// might be possible. - fn is_exact(&self) -> bool { - false - } + fn is_exact(&self) -> bool; } /// Matches everything. @@ -95,11 +85,22 @@ fn file_set(&self) -> HashSet<&HgPath> { HashSet::new() } - + fn exact_match(&self, _filename: impl AsRef) -> bool { + false + } + fn matches(&self, _filename: impl AsRef) -> bool { + true + } fn visit_children_set( &self, _directory: impl AsRef, ) -> VisitChildrenSet { VisitChildrenSet::Recursive } + fn matches_everything(&self) -> bool { + true + } + fn is_exact(&self) -> bool { + false + } }