Crate lure

Crate lure 

Source
Expand description

This crate contains a macro to generate a lazy Regex and perform regex validation. The code fails to compile if the regex is invalid.

§Usage

This Rust crate helps prevent common pitfalls when working with regular expressions by ensuring patterns are valid at compile time and avoiding redundant compilations. It leverages the standard library OnceLock to compile regexes only once and uses a procedural macro for compile-time validation, improving both safety and performance. The only dependency in the crate is regex

Example:

use lure::regex;

// Password regex
let re = regex!("[0-9a-f]+");
assert!(re.is_match("Test1234ccc#"));

Note: clippy already provides a lint that validates regexes. The usage of this crate is more about avoiding the overhead of creating the regex multiple with the added benefit of compile time validation.

Re-exports§

pub use lure_macros;

Macros§

regex
Generates a lazy regex::Regex and perform regex validation. The code fails to compile if the regex is invalid.