1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! This crate contains a macro to generate a lazy
//! [`Regex`](https://docs.rs/regex/latest/regex/struct.Regex.html) 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 `OnceCell` 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:
//! ```rust
//! 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.
//!
pub use lure_macros;
pub type Regex = Regex;
pub type Lock = OnceLock;
/// Generate a static regex.
;