pub struct MatchRef<'c> {
pub start: usize,
pub end: usize,
/* private fields */
}Expand description
One match, borrowing the cursor that produced it.
crate::Match owns a share of the pattern’s register names, which costs
the two atomics of a clone and a drop and gives every match a destructor to
run. Over fifty thousand matches that is 30.2 nanoseconds each, measured
against the same loop building matches that bind nothing. A caller that
reads each match in turn and keeps none of them pays neither here.
Borrowed from the cursor and not from the input, so a view is invalidated by
asking for the next match. MatchRef::to_match takes an owned copy where
one is wanted.
Fields§
§start: usizeInclusive start byte offset of the match in the input.
end: usizeExclusive end byte offset of the match in the input.
Implementations§
Source§impl<'c> MatchRef<'c>
impl<'c> MatchRef<'c>
Sourcepub fn captures(&self) -> &[Span]
pub fn captures(&self) -> &[Span]
The spans this match’s registers bound, in the order Self::names
holds their names.
Sourcepub fn names(&self) -> &[String]
pub fn names(&self) -> &[String]
The register names, in the order Self::captures holds their spans.