#regex #compile-time #lazy-evaluation #static #convenience #validate #function

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

#24 in #convenience

Download history 22/week @ 2024-01-15 14/week @ 2024-01-22 10/week @ 2024-02-12 38/week @ 2024-02-19 50/week @ 2024-02-26 11/week @ 2024-03-04 20/week @ 2024-03-11 4/week @ 2024-03-25 27/week @ 2024-04-01

52 downloads per month
Used in cargo-cocoapods

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
~88K SLoC