rust-lang / rust-lang/glob

Make PatternToken public

Open
#185 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
595
Forks
93
PR merge metrics
No merged PRs in 30d

Description

glob provides nice parsing and matching facilities, and sometimes it's important to reach into the Pattern and inspect the individual PatternToken elements themselves.

Use case

Given some fn extend_with_literals(input: &str, pattern: Pattern), identify whether the input is a valid prefix of pattern and determine any subsequent literal characters from the pattern that would better qualify the input.

Example
assert_eq!(
    extend_with_literals("pr", Pattern::new("pr[e]?ix").unwrap()),
    "pre"
);

assert_eq!(
    extend_with_literals("pre", Pattern::new("pr[e]?ix").unwrap()),
    "pre"
);

assert_eq!(
    extend_with_literals("pref", Pattern::new("pr[e]?ix").unwrap()),
    "prefix"
);

This makes it possible to optimize glob in over a nonstandard async filesystem where enumeration is very expensive and irrelevant matches are common.

It's easier to implement this by having access to the PatternToken and not needing to reimplement AnyWithin/AnyExcept parsing.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the PatternToken definition and the Pattern parsing entry points, then read how token visibility currently limits inspection. Make PatternToken publicly accessible so callers can inspect parsed pattern elements without reimplementing parsing, and verify the examples in the issue can use the public API.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.