Struct regex_automata::dfa::onepass::Slots

source ·
struct Slots(u32);
Expand description

The set of epsilon transitions indicating that the current position in a search should be saved to a slot.

This only represents explicit slots. So for example, the pattern [a-z]+([0-9]+)([a-z]+) has:

  • 3 capturing groups, thus 6 slots.
  • 1 implicit capturing group, thus 2 implicit slots.
  • 2 explicit capturing groups, thus 4 explicit slots.

While implicit slots are represented by epsilon transitions in an NFA, we do not explicitly represent them here. Instead, implicit slots are assumed to be present and handled automatically in the search code. Therefore, that means we only need to represent explicit slots in our epsilon transitions.

Its representation is a bit set. The bit ‘i’ is set if and only if there exists an explicit slot at index ‘c’, where ‘c = (#patterns * 2) + i’. That is, the bit ‘i’ corresponds to the first explicit slot and the first explicit slot appears immediately following the last implicit slot. (If this is confusing, see GroupInfo for more details on how slots works.)

A single Slots represents all the active slots in a sub-graph of an NFA, where all the states are connected by epsilon transitions. In effect, when traversing the one-pass DFA during a search, all slots set in a particular transition must be captured by recording the current search position.

The API of Slots requires the caller to handle the explicit slot offset. That is, a Slots doesn’t know where the explicit slots start for a particular NFA. Thus, if the callers see’s the bit ‘i’ is set, then they need to do the arithmetic above to find ‘c’, which is the real actual slot index in the corresponding NFA.

Tuple Fields§

§0: u32

Implementations§

source§

impl Slots

source

const LIMIT: usize = 32usize

source

fn insert(self, slot: usize) -> Slots

Insert the slot at the given bit index.

source

fn remove(self, slot: usize) -> Slots

Remove the slot at the given bit index.

source

fn is_empty(self) -> bool

Returns true if and only if this set contains no slots.

source

fn iter(self) -> SlotsIter

Returns an iterator over all of the set bits in this set.

source

fn apply(self, at: usize, caller_explicit_slots: &mut [Option<NonMaxUsize>])

For the position at in the current haystack, copy it to caller_explicit_slots for all slots that are in this set.

Callers may pass a slice of any length. Slots in this set bigger than the length of the given explicit slots are simply skipped.

The slice must correspond only to the explicit slots and the first element of the slice must always correspond to the first explicit slot in the corresponding NFA.

Trait Implementations§

source§

impl Clone for Slots

source§

fn clone(&self) -> Slots

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Slots

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Copy for Slots

Auto Trait Implementations§

§

impl Freeze for Slots

§

impl RefUnwindSafe for Slots

§

impl Send for Slots

§

impl Sync for Slots

§

impl Unpin for Slots

§

impl UnwindSafe for Slots

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.