mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-10 05:59:25 +02:00
globset: add opt-in Arbitrary
trait implementations
This feature is mandatory when using `Glob` in fuzz testing. Closes #2720
This commit is contained in:
committed by
Andrew Gallant
parent
5548e538b1
commit
95979048c9
@@ -72,6 +72,7 @@ impl MatchStrategy {
|
||||
/// It cannot be used directly to match file paths, but it can be converted
|
||||
/// to a regular expression string or a matcher.
|
||||
#[derive(Clone, Debug, Eq)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
pub struct Glob {
|
||||
glob: String,
|
||||
re: String,
|
||||
@@ -194,6 +195,7 @@ pub struct GlobBuilder<'a> {
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
struct GlobOptions {
|
||||
/// Whether to match case insensitively.
|
||||
case_insensitive: bool,
|
||||
@@ -220,6 +222,7 @@ impl GlobOptions {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
struct Tokens(Vec<Token>);
|
||||
|
||||
impl std::ops::Deref for Tokens {
|
||||
@@ -236,6 +239,7 @@ impl std::ops::DerefMut for Tokens {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
enum Token {
|
||||
Literal(char),
|
||||
Any,
|
||||
|
@@ -94,6 +94,19 @@ Standard Unix-style glob syntax is supported:
|
||||
|
||||
A `GlobBuilder` can be used to prevent wildcards from matching path separators,
|
||||
or to enable case insensitive matching.
|
||||
|
||||
# Crate Features
|
||||
|
||||
This crate includes optional features that can be enabled if necessary.
|
||||
These features are not required but may be useful depending on the use case.
|
||||
|
||||
The following features are available:
|
||||
|
||||
* **arbitrary** -
|
||||
Enabling this feature introduces a public dependency on the
|
||||
[`arbitrary`](https://crates.io/crates/arbitrary)
|
||||
crate. Namely, it implements the `Arbitrary` trait from that crate for the
|
||||
[`Glob`] type. This feature is disabled by default.
|
||||
*/
|
||||
|
||||
#![deny(missing_docs)]
|
||||
|
Reference in New Issue
Block a user