Make PatternToken public

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

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
tooling

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.

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.

Dominant language
Rust
Stars
597
Forks
97
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from rust-lang/glob

All issues in rust-lang/glob

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.