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

source

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.

source

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.

source

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.

source

fn pattern_len(&self) -> usize

Return the total number of patterns represented by this capture slot info.

source

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.

source

fn small_slot_len(&self) -> SmallIndex

Return the total number of slots in this capture slot info as a “small index.”

Trait Implementations§

source§

impl Debug for GroupInfoInner

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for GroupInfoInner

source§

fn default() -> GroupInfoInner

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.