Struct regex_automata::util::captures::GroupInfoInner
source · struct GroupInfoInner {
slot_ranges: Vec<(SmallIndex, SmallIndex)>,
name_to_index: Vec<HashMap<Arc<str>, SmallIndex>>,
index_to_name: Vec<Vec<Option<Arc<str>>>>,
memory_extra: usize,
}
Expand description
The inner guts of GroupInfo
. This type only exists so that it can
be wrapped in an Arc
to make GroupInfo
reference counted.
Fields§
§slot_ranges: Vec<(SmallIndex, SmallIndex)>
§name_to_index: Vec<HashMap<Arc<str>, SmallIndex>>
§index_to_name: Vec<Vec<Option<Arc<str>>>>
§memory_extra: usize
Implementations§
source§impl GroupInfoInner
impl GroupInfoInner
sourcefn add_first_group(&mut self, pid: PatternID)
fn add_first_group(&mut self, pid: PatternID)
This adds the first unnamed group for the given pattern ID. The given pattern ID must be zero if this is the first time this method is called, or must be exactly one more than the pattern ID supplied to the previous call to this method. (This method panics if this rule is violated.)
This can be thought of as initializing the GroupInfo state for the given pattern and closing off the state for any previous pattern.
sourcefn add_explicit_group<N: AsRef<str>>(
&mut self,
pid: PatternID,
group: SmallIndex,
maybe_name: Option<N>,
) -> Result<(), GroupInfoError>
fn add_explicit_group<N: AsRef<str>>( &mut self, pid: PatternID, group: SmallIndex, maybe_name: Option<N>, ) -> Result<(), GroupInfoError>
Add an explicit capturing group for the given pattern with the given index. If the group has a name, then that must be given as well.
Note that every capturing group except for the first or zeroth group is explicit.
This returns an error if adding this group would result in overflowing slot indices or if a capturing group with the same name for this pattern has already been added.
sourcefn fixup_slot_ranges(&mut self) -> Result<(), GroupInfoError>
fn fixup_slot_ranges(&mut self) -> Result<(), GroupInfoError>
This corrects the slot ranges to account for the slots corresponding to the zeroth group of each pattern. That is, every slot range is offset by ‘pattern_len() * 2’, since each pattern uses two slots to represent the zeroth group.
sourcefn pattern_len(&self) -> usize
fn pattern_len(&self) -> usize
Return the total number of patterns represented by this capture slot info.
sourcefn group_len(&self, pid: PatternID) -> usize
fn group_len(&self, pid: PatternID) -> usize
Return the total number of capturing groups for the given pattern. If the given pattern isn’t valid for this capture slot info, then 0 is returned.
sourcefn small_slot_len(&self) -> SmallIndex
fn small_slot_len(&self) -> SmallIndex
Return the total number of slots in this capture slot info as a “small index.”