#regex #compile-time #validation #lazy-evaluation #static #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

#529 in Science

Download history 618/week @ 2024-10-12 1120/week @ 2024-10-19 857/week @ 2024-10-26 502/week @ 2024-11-02 272/week @ 2024-11-09 566/week @ 2024-11-16 444/week @ 2024-11-23 391/week @ 2024-11-30 528/week @ 2024-12-07 888/week @ 2024-12-14 254/week @ 2024-12-21 408/week @ 2024-12-28 587/week @ 2025-01-04 849/week @ 2025-01-11 1319/week @ 2025-01-18 1308/week @ 2025-01-25

4,309 downloads per month
Used in 5 crates (3 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

~5.5MB
~109K SLoC