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
impl Slots
const LIMIT: usize = 32usize
sourcefn apply(self, at: usize, caller_explicit_slots: &mut [Option<NonMaxUsize>])
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)