Struct regex_automata::meta::regex::RegexI
source · struct RegexI {
strat: Arc<dyn Strategy>,
info: RegexInfo,
}
Expand description
The internal implementation of Regex
, split out so that it can be wrapped
in an Arc
.
Fields§
§strat: Arc<dyn Strategy>
The core matching engine.
Why is this reference counted when RegexI is already wrapped in an Arc?
Well, we need to capture this in a closure to our Pool
below in order
to create new Cache
values when needed. So since it needs to be in
two places, we make it reference counted.
We make RegexI
itself reference counted too so that Regex
itself
stays extremely small and very cheap to clone.
info: RegexInfo
Metadata about the regexes driving the strategy. The metadata is also usually stored inside the strategy too, but we put it here as well so that we can get quick access to it (without virtual calls) before executing the regex engine. For example, we use this metadata to detect a subset of cases where we know a match is impossible, and can thus avoid calling into the strategy at all.
Since RegexInfo
is stored in multiple places, it is also reference
counted.