regex!() { /* proc-macro */ }Expand description
Creates a generator from a regular expression, validated at compile time.
This macro takes a string literal representing a regular expression and produces a generator that yields strings matching that pattern. The regex is parsed and validated at compile time, so any errors in the pattern will result in a compilation failure.
ยงExamples
#[check(regex!("[a-zA-Z0-9]{1,10}"))]
fn has_alphanumeric_content(s: String) {
assert!(s.chars().all(|c| c.is_alphanumeric()));
assert!(s.len() >= 1 && s.len() <= 10);
}Converts the input string literal to a regex while validating proper syntax.