rust-lang / rust-lang/glob

[Feature request] add is_literal(pattern)

Open
#72 7 comments 2 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

It would be really helpful to have a function that tells you whether the input pattern contains any globs.

Basically a version of this that ignores escaped characters:

const GLOB_CHARS: [char; 3] = ['?', '*', '['];

pub fn is_literal(pattern: &str) -> bool {
    // Need to check the characters aren't escaped here.
    !pattern.chars().any(|c| GLOB_CHARS.contains(&c))
}

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

Review the existing public API and pattern-escaping behavior before adding the requested is_literal(pattern) helper. Confirm how escaped glob characters are treated and add coverage for literal, unescaped-glob, and escaped-glob patterns; done means the helper reliably distinguishes them.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.