You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a wrapper around `regex_automata`'s `Lazy` as a simple way to
construct a `Regex` that is compiled once but used multiple times.
Sample usage:
if regex!(r"\d+").is_match("123") { /* ... */ }
let re: &Regex = regex!(r"\d+");
This idea has been discussed in #709. To address a few of the concerns
from that issue:
1. More than 1 `regex!` can be used in a block (for the anonymous
version, the name is in a scope).
2. Using `regex_automata`'s `Lazy` means there are no MSRV concerns, and
this works without std.
3. There is no compile-time checking. The docs make it clear that
`regex!` should not be used with invalid regex and suggest enabling
the clippy lint, leaving the door somewhat open for e.g. a `const fn`
syntax validator in the future (though this seems unlikely).
A `regex::bytes::regex!` version is also included.
Closes#709
0 commit comments