MCPcopy Index your code
hub / github.com/cloudflare/wildcard

github.com/cloudflare/wildcard @v0.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.0 ↗ · + Follow
89 symbols 217 edges 7 files 6 documented · 7%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Build Status Dependency status crates.io Downloads Github stars Documentation License

wildcard

wildcard is a rust crate for wildcard matching.

Here's how to use it:

let wildcard = Wildcard::new("*foo?*bar".as_bytes()).unwrap();

assert!(wildcard.is_match("fooofooobar".as_bytes()));

Special characters can be escaped to represent their literal symbol:

let wildcard = Wildcard::new(r"\*\?".as_bytes()).unwrap();

assert!(!wildcard.is_match("ab".as_bytes()));
assert!(wildcard.is_match("*?".as_bytes()));

You can also capture the substring that matched the metasymbols of the wildcard:

let wildcard = Wildcard::new("* is a * style?".as_bytes()).unwrap();

let captures: Vec<&[u8]> = wildcard.captures("Lambic is a beer style!".as_bytes()).unwrap();

assert_eq!(captures, ["Lambic".as_bytes(), "beer".as_bytes(), "!".as_bytes()]);

String matching

For performance reasons wildcard does not match directly on strings, but it supports matching on slices of chars:

let p = "*foo?*bar".chars().collect::<Vec<_>>();
let wildcard = Wildcard::new(&p).unwrap();

assert!(wildcard.is_match(&"fooofooobar".chars().collect::<Vec<_>>()));

Matching customization

With wildcard you can configure these properties of a wildcard:

  1. Configure the symbols for the metasymbols * and ? as well as the escape symbol.
  2. Support for the metasymbol ? can be disabled.
  3. Support for escaping can be disabled.
  4. Support for case-insensitive matching.

Extension points exported contracts — how you extend this code

WildcardSymbol (Interface)
This trait defined the alphabet a wildcard can be used on. [2 implementers]
src/lib.rs

Core symbols most depended-on inside this repo

build
called by 21
src/lib.rs
compile
called by 17
benches/benchmark.rs
is_symbol
called by 15
src/lib.rs
captures
called by 11
src/lib.rs
is_match
called by 9
src/lib.rs
matches
called by 7
benches/benchmark.rs
matches_compiled
called by 7
benches/benchmark.rs
case_insensitive
called by 6
src/lib.rs

Shape

Function 47
Method 26
Class 13
Enum 2
Interface 1

Languages

Rust100%

Modules by API surface

src/lib.rs69 symbols
benches/benchmark.rs17 symbols
fuzz/src/lib.rs3 symbols

For agents

$ claude mcp add wildcard \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact