Struct regex_automata::HalfMatch
source · pub struct HalfMatch { /* private fields */ }
Expand description
A representation of “half” of a match reported by a DFA.
This is called a “half” match because it only includes the end location (or start location for a reverse search) of a match. This corresponds to the information that a single DFA scan can report. Getting the other half of the match requires a second scan with a reversed DFA.
A half match also includes the pattern that matched. The pattern is
identified by an ID, which corresponds to its position (starting from 0
)
relative to other patterns used to construct the corresponding DFA. If only
a single pattern is provided to the DFA, then all matches are guaranteed to
have a pattern ID of 0
.
Implementations§
source§impl HalfMatch
impl HalfMatch
sourcepub fn new(pattern: PatternID, offset: usize) -> HalfMatch
pub fn new(pattern: PatternID, offset: usize) -> HalfMatch
Create a new half match from a pattern ID and a byte offset.
sourcepub fn must(pattern: usize, offset: usize) -> HalfMatch
pub fn must(pattern: usize, offset: usize) -> HalfMatch
Create a new half match from a pattern ID and a byte offset.
This is like HalfMatch::new
, but accepts a usize
instead of a
PatternID
. This panics if the given usize
is not representable
as a PatternID
.