Enum WhichCaptures
pub enum WhichCaptures
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,
PikeVMorBoundedBacktracker).Perhaps more confusingly, using this option with such an engine means that an
is_matchroutine could reporttruewhenfindreportsNone. 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 returnNonefromfindroutines 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::findwill always returnNonewhen configured with this option.
Implementations
impl WhichCaptures
fn is_none(&self) -> boolReturns true if this configuration indicates that no capture states should be produced in an NFA.
fn is_any(&self) -> boolReturns true if this configuration indicates that some capture states should be added to an NFA. Note that this might only include capture states for implicit capture groups.
Trait Implementations
impl Clone for WhichCaptures
fn clone(&self) -> Self
impl Copy for WhichCaptures
impl Debug for WhichCaptures
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for WhichCaptures
fn default() -> WhichCaptures
Auto Trait Implementations
impl Freeze for WhichCaptures
impl RefUnwindSafe for WhichCaptures
impl Send for WhichCaptures
impl Sync for WhichCaptures
impl Unpin for WhichCaptures
impl UnsafeUnpin for WhichCaptures
impl UnwindSafe for WhichCaptures
Blanket Implementations
impl<T> Any for WhichCaptures
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for WhichCaptures
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for WhichCaptures
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for WhichCaptures
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for WhichCaptures
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for WhichCaptures
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for WhichCaptures
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for WhichCaptures
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for WhichCaptures
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>