#regex #compile-time #lazy-evaluation #static #validation #convenience #once-cell

regex_static

Compile-time validated regex, with convenience functions for lazy and static regexes

2 releases

0.1.1 Mar 20, 2021
0.1.0 Mar 4, 2021

#457 in Science

Download history 576/week @ 2024-11-17 440/week @ 2024-11-24 400/week @ 2024-12-01 528/week @ 2024-12-08 875/week @ 2024-12-15 255/week @ 2024-12-22 405/week @ 2024-12-29 604/week @ 2025-01-05 841/week @ 2025-01-12 1331/week @ 2025-01-19 1313/week @ 2025-01-26 498/week @ 2025-02-02 937/week @ 2025-02-09 943/week @ 2025-02-16 1494/week @ 2025-02-23 1559/week @ 2025-03-02

4,950 downloads per month
Used in 9 crates (4 directly)

Apache-2.0 OR MIT OR CC0-1.0

4KB

regex_static

Compile-time validation of regex::Regex.

Examples

Lazy regex

Uses once_cell to lazily create the regex.

static RE: Lazy<Regex> = regex_static::lazy_regex!("^yesss$");

Static regex

Also uses once_cell, but works inline (will therefore reuse the same instance of the regex each function call).

let some_regex = regex_static::static_regex!("^yesss$");

Ordinary regex

Will create an owned Regex, just like calling Regex::new(...) but with compile-time validation.

let ordinary_regex = regex_static::regex!("^yesss$");

lib.rs:

Compile-time validation of regex::Regex.

Examples

Lazy regex

Uses once_cell to lazily create the regex.

static RE: Lazy<Regex> = regex_static::lazy_regex!("^yesss$");

Static regex

Also uses once_cell, but works inline (will therefore reuse the same instance of the regex each function call).

let some_regex = regex_static::static_regex!("^yesss$");

Ordinary regex

Will create an owned Regex, just like calling Regex::new(...) but with compile-time validation.

let ordinary_regex = regex_static::regex!("^yesss$");

Dependencies

~3.5–4.5MB
~91K SLoC