BurntSushi / BurntSushi/globset
`Debug` implementation of `GlobSetBuilder` is very verbose
- Dominant language
- Rust
- Stars
- 47
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
The `Debug` implementation of `GlobSetBuilder` is quite noisy. For better introspectability in consuming packages, it would be perfect if one of two things could be implemented, so the `Debug` implementation can be adjusted (favorite) or is more readable:
1. An `IntoIterator` implementation for `&GlobSetBuilder`, so we can use the `Display` implementation of `Glob` where applicable. This would be a non-invasive addition, as the consumer can decide what style they want.
2. A `Debug` implementation for `GlobSetBuilder` that does 1., i.e., prints `Glob` via `Display`.
I'm happy to send a PR for either of which, if this is a good match.
### Example
``` rust
#[cfg(test)]
mod tests {
use globset::{Glob, GlobSetBuilder};
#[test]
fn test() -> Result<(), Box> {
let mut builder = GlobSetBuilder::new();
builder.add(Glob::new("src/**/*.rs")?);
builder.add(Glob::new("*.txt")?);
builder.add(Glob::new("docs/**/*.md")?);
println!("{:#?}", builder);
Ok(())
}
}
```
### Current Result
``` rust
GlobSetBuilder {
pats: [
Glob {
glob: "src/**/*.rs",
re: "(?-u)^src(?:/|/.*/).*\\.rs$",
opts: GlobOptions {
case_insensitive: false,
literal_separator: false,
backslash_escape: true,
},
tokens: Tokens(
[
Literal(
's',
),
Literal(
'r',
),
Literal(
'c',
),
RecursiveZeroOrMore,
ZeroOrMore,
Literal(
'.',
),
Literal(
'r',
),
Literal(
's',
),
],
),
},
Glob {
glob: "*.txt",
re: "(?-u)^.*\\.txt$",
opts: GlobOptions {
case_insensitive: false,
literal_separator: false,
backslash_escape: true,
},
tokens: Tokens(
[
ZeroOrMore,
Literal(
'.',
),
Literal(
't',
),
Literal(
'x',
),
Literal(
't',
),
],
),
},
Glob {
glob: "docs/**/*.md",
re: "(?-u)^docs(?:/|/.*/).*\\.md$",
opts: GlobOptions {
case_insensitive: false,
literal_separator: false,
backslash_escape: true,
},
tokens: Tokens(
[
Literal(
'd',
),
Literal(
'o',
),
Literal(
'c',
),
Literal(
's',
),
RecursiveZeroOrMore,
ZeroOrMore,
Literal(
'.',
),
Literal(
'm',
),
Literal(
'd',
),
],
),
},
],
}
```
### Ideal Result:
``` rust
GlobSetBuilder {
pats: [
"src/**/*.rs",
"*.txt",
"docs/**/*.md",
]
}
```
Oh and thanks for this library, it is awesome!
Contributor guide
No contributing guide indexed for this repository
Research direction
Locate the GlobSetBuilder and Glob entry points, then inspect the existing Debug output and how the builder stores its patterns. Compare the proposed IntoIterator and Debug-formatting approaches with the ideal output; done means the builder is more readable without exposing the compiled regex and token details.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100