pub struct CaptureSlots { /* private fields */ }Expand description
Where each register landed in one match, in a buffer sized by the pattern and refilled in place.
Built once with CaptureSlots::of and passed to captures_read or
captures_read_at for each match. Slot order is the order the pattern
binds its names, which is the order crate::capture_names reports; it is
not the order crate::Match::captures uses, which is sorted by name.
A register the match did not bind reads back as None, which is what
distinguishes it from one that bound an empty span.
Implementations§
Source§impl CaptureSlots
impl CaptureSlots
Sourcepub fn get(&self, i: usize) -> Option<Span>
pub fn get(&self, i: usize) -> Option<Span>
The byte span slot i bound, or None where it bound nothing.
Sourcepub fn by_name(&self, name: &str) -> Option<Span>
pub fn by_name(&self, name: &str) -> Option<Span>
The byte span the register called name bound.
Sourcepub fn extent(&self, i: usize) -> Option<(usize, usize)>
pub fn extent(&self, i: usize) -> Option<(usize, usize)>
The significant tokens slot i bound, as a half-open index pair into
the token stream.
The engine names a match by the token indices it runs between, so this is what it had before it converted to bytes. A byte matcher reports no such pair, because a byte offset does not say which token it is in.
Sourcepub fn matched(&self) -> Option<Span>
pub fn matched(&self) -> Option<Span>
The span of the whole match the buffer was last filled from.
Sourcepub fn matched_extent(&self) -> Option<(usize, usize)>
pub fn matched_extent(&self) -> Option<(usize, usize)>
The significant tokens the whole match spanned.
Sourcepub fn matched_tokens(&self) -> Option<usize>
pub fn matched_tokens(&self) -> Option<usize>
How many significant tokens the whole match spanned.