#regex #compile-time #static

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

#1824 in Development tools

Download history 219/week @ 2024-07-03 251/week @ 2024-07-10 623/week @ 2024-07-17 821/week @ 2024-07-24 361/week @ 2024-07-31 270/week @ 2024-08-07 419/week @ 2024-08-14 536/week @ 2024-08-21 1412/week @ 2024-08-28 828/week @ 2024-09-04 1198/week @ 2024-09-11 844/week @ 2024-09-18 712/week @ 2024-09-25 559/week @ 2024-10-02 726/week @ 2024-10-09 798/week @ 2024-10-16

2,892 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

~3.5–4.5MB
~91K SLoC