Closed BurntSushi closed 7 years ago
I've given this some thought, and this is where I'm currently at:
Regex
. Knobs can be set using methods. This permits expanding the set of the knobs in the future in an API compatible way.Regex
will continue to need an alternate constructor, much like how Vec
or HashMap
have alternate constructors. For example, Regex::with_config
or something.
Regex
currently has two constructors,Regex::new
andRegex::with_size_limit
. The latter is the same as the former, except it allows one to bound the size of the compiled program. The idea is here to control how much memory is used if a regex is compiled from an untrusted source.There are other knobs that seem useful for exposing to the user:
regex-syntax
for recursively simplifying a regex. (It'd be nice to move this to a stack on the heap, but it seems tricky.)There are other knobs that maybe shouldn't be exposed, but could:
It's not clear what, if any, of these things should be exposed. I feel like the knobs that control memory bounds should be accessible to callers, because when you need them, you really need them.