Probably not useful for the initial release but something to consider for later. This could be done three ways:
- add that information as a flag to the repl from construction
- pre-check the resolvers at extraction
- capture lazily instead of eagerly
The first two complicate resolution as it means resolve has to be duplicated to handle the None/Replacement cases separately, the latter probably just means constructing the capture once using OnceCell (/ LazyCell) instead of using a Capture parameter.
Later clarification for myself: this is about calling re.capture during extraction e.g.
|
let c = re.captures(ua)?; |
::None and ::Replacement resolver variants have no need for the capture data, although that means resolve would need to be faillible. Then again, we could just expect/unwrap since by definition matching should only yield matching regexes, so captures should always succeed.
Probably not useful for the initial release but something to consider for later. This could be done three ways:
The first two complicate resolution as it means
resolvehas to be duplicated to handle theNone/Replacementcases separately, the latter probably just means constructing the capture once usingOnceCell(/LazyCell) instead of using aCaptureparameter.Later clarification for myself: this is about calling
re.captureduring extraction e.g.uap-rust/ua-parser/src/lib.rs
Line 237 in 2cd7c6a
::Noneand::Replacementresolver variants have no need for the capture data, although that meansresolvewould need to be faillible. Then again, we could justexpect/unwrapsince by definitionmatchingshould only yield matching regexes, socapturesshould always succeed.