pub enum WhichCaptures {
All,
Implicit,
None,
}
Expand description
A configuration indicating which kinds of
State::Capture
states to include.
This configuration can be used with Config::which_captures
to control
which capture states are compiled into a Thompson NFA.
The default configuration is WhichCaptures::All
.
Variants§
All
All capture states, including those corresponding to both implicit and explicit capture groups, are included in the Thompson NFA.
Implicit
Only capture states corresponding to implicit capture groups are included. Implicit capture groups appear in every pattern implicitly and correspond to the overall match of a pattern.
This is useful when one only cares about the overall match of a pattern. By excluding capture states from explicit capture groups, one might be able to reduce the memory usage of a multi-pattern regex substantially if it was otherwise written to have many explicit capture groups.
None
No capture states are compiled into the Thompson NFA.
This is useful when capture states are either not needed (for example, if one is only trying to build a DFA) or if they aren’t supported (for example, a reverse NFA).
§Warning
Callers must be exceedingly careful when using this
option. In particular, not all regex engines support
reporting match spans when using this option (for example,
PikeVM
or
BoundedBacktracker
).
Perhaps more confusingly, using this option with such an
engine means that an is_match
routine could report true
when find
reports None
. This is generally not something
that should happen, but the low level control provided by
this crate makes it possible.
Similarly, any regex engines (like meta::Regex
)
should always return None
from find
routines when this option is
used, even if some of its internal engines could find the match
boundaries. This is because inputs from user data could influence
engine selection, and thus influence whether a match is found or not.
Indeed, meta::Regex::find
will always return None
when configured
with this option.
Implementations§
Trait Implementations§
Source§impl Clone for WhichCaptures
impl Clone for WhichCaptures
Source§fn clone(&self) -> WhichCaptures
fn clone(&self) -> WhichCaptures
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more