D7178: [RFC] rust-matchers: add `Matcher` trait and implement `AlwaysMatcher`
yuja (Yuya Nishihara)
phabricator at mercurial-scm.org
Wed Nov 6 07:16:08 EST 2019
yuja added a comment.
> +pub trait Matcher {
> + /// Explicitly listed files
> + fn file_set(&self) -> HashSet<&HgPath>;
[...]
> + /// Matcher will match everything and `files_set()` will be empty:
> + /// optimization might be possible.
> + fn matches_everything(&self) -> bool {
> + false
> + }
Maybe better to not provide the default implementations since not a few
matchers will have to reimplement them.
> +impl Matcher for AlwaysMatcher {
> + fn file_set(&self) -> HashSet<&HgPath> {
> + HashSet::new()
> + }
> +
> + fn visit_children_set(
> + &self,
> + _directory: impl AsRef<HgPath>,
> + ) -> VisitChildrenSet {
> + VisitChildrenSet::Recursive
> + }
Need to implement `matches()` and `matches_everything()`?
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D7178/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D7178
To: Alphare, #hg-reviewers
Cc: yuja, martinvonz, spectral, durin42, kevincox, mercurial-devel
More information about the Mercurial-devel
mailing list