Page MenuHomePhabricator

rust-matchers: improve `Matcher` trait ergonomics
ClosedPublic

Authored by Alphare on Fri, Nov 29, 12:56 PM.

Details

Summary

VisitChildrenSet has no need to own the set, this will save allocations.

The file_set return type change is motivated by both ergonomics and... being
able to compile code.
The AlwaysMatcher does not store a file_set, which requires it to return an
owned HashSet, which in turn would change our return type to Cow<&HgPath>
(lifetimes omitted). This is both un-ergonomic and troublesome for more
complex lifetime issues (especially with the upcoming FileMatcher in the
following patch).

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Alphare created this revision.Fri, Nov 29, 12:56 PM
kevincox accepted this revision.Mon, Dec 2, 8:09 AM
kevincox added inline comments.
rust/hg-core/src/matchers.rs
87

Another option here would just to have a global empty hash set.

Alphare added inline comments.Mon, Dec 2, 9:20 AM
rust/hg-core/src/matchers.rs
87

I feel like an Option is more explicit and less contrived, but yes.

pulkit accepted this revision.Tue, Dec 10, 10:13 AM
This revision is now accepted and ready to land.Tue, Dec 10, 10:13 AM
This revision was automatically updated to reflect the committed changes.