Closed
Description
I've been trying to reimplement the following logic in Rust: Lua, PHP.
Basically, they use a regular expression to unescape some sequences and throw an exception if it's not a known one. I tried to do a similar thing but ran into an issue that Replacer
is expected to be a function that returns String
, not Result<String, _>
.
I circumvented this by panic!()
-ing inside my Replacer
and wrapping a replace_all()
call in std::panic::catch_unwind()
but, AFAIK, it's a pretty terrible solution.
Is there a better approach? (Other than not using regular expressions for deserializing, haha)