Cross platform single glob and glob set matching. Glob set matching is the process of matching one or more glob patterns against a single candidate path simultaneously, and returning all of the globs that matched.
Dual-licensed under MIT or the UNLICENSE.
Add this to your
 = "0.3"
serde1: Enables implementing Serde traits on the
Example: one glob
This example shows how to match a single glob against a single file path.
use Glob; let glob = new?.compile_matcher; assert!; assert!; assert!;
Example: configuring a glob matcher
This example shows how to use a
GlobBuilder to configure aspects of match
semantics. In this example, we prevent wildcards from matching path separators.
use GlobBuilder; let glob = new .literal_separator.build?.compile_matcher; assert!; assert!; // no longer matches assert!;
Example: match multiple globs at once
This example shows how to match multiple glob patterns at once.
use ; let mut builder = new; // A GlobBuilder can be used to configure each glob's match semantics // independently. builder.add; builder.add; builder.add; let set = builder.build?; assert_eq!;
This crate implements globs by converting them to regular expressions, and
executing them with the
For single glob matching, performance of this crate should be roughly on par
with the performance of the
*_regex correspond to benchmarks for this library while
correspond to benchmarks for the
Optimizations in the
regex crate may propel this library past
particularly when matching longer paths.
test ext_glob ... bench: 425 ns/iter (+/- 21) test ext_regex ... bench: 175 ns/iter (+/- 10) test long_glob ... bench: 182 ns/iter (+/- 11) test long_regex ... bench: 173 ns/iter (+/- 10) test short_glob ... bench: 69 ns/iter (+/- 4) test short_regex ... bench: 83 ns/iter (+/- 2)
The primary performance advantage of this crate is when matching multiple
globs against a single path. With the
glob crate, one must match each glob
synchronously, one after the other. In this crate, many can be matched
simultaneously. For example:
test many_short_glob ... bench: 1,063 ns/iter (+/- 47) test many_short_regex_set ... bench: 186 ns/iter (+/- 11)
Comparison with the
- Supports alternate "or" globs, e.g.,
- Can match non-UTF-8 file paths correctly.
- Supports matching multiple globs at once.
- Doesn't provide a recursive directory iterator of matching file paths, although I believe this crate should grow one eventually.
- Supports case insensitive and require-literal-separator match options, but doesn't support the require-literal-leading-dot option.