ripgrep
ripgrep copied to clipboard
feat(globset): better way to see if ALL globs match
A have a use case where I have a set of 1 or more globs, and want to know if all of them match, rather than if any of them match.
I can of course use a Vec<Glob> and do something like globs.iter().all(|g| g.is_match(path)), but it sounds like using a GlobSet may be more efficient, since it can use a single pass.
I think I can accomplish this with glob_set.matches(path).len() == glob_set.len(), but then it has to allocate a Vec, and then I just throw it away, because I only care about the length.
Possible ways this could be improved are:
- Add a
matches_allmethod that returns true if all globs match (fwiw, I'd also like that onRegexSet) - Return an iterator similar to how
RegexSet.matchesreturns an iterator, so it can be counted instead of storing in a Vec.