4 ms·
Except when you want to compile a regex at runtime from some input (like a config file for example).
by bombela 4y ago
Except when you want to compile a regex at runtime from some input (like a config file for example).
- afavour 4y agoBut in that situation you'd want a Result because it absolutely could fail at runtime. And you wouldn't want to use unwrap on that because user input could tank your program. I think it would make sense for there to be some kind of compile-time macro for regexes. If the regex is based on a constant string then it should be a build error when that regex isn't valid. And the existing API (result, unwrap and all) would work great for non-constant strings.