3 ms·
You could almost write a `check!` macro for rust that would have the same semantics. You can obviously already write one when no `handle` exists (it'd just be `
by eximius 8y ago
You could almost write a `check!` macro for rust that would have the same semantics. You can obviously already write one when no `handle` exists (it'd just be `try!` or `?`), but I can't think of how you'd build up the handles like they describe without a procedural macro.
You likely could do something semantically equivalent with procedural macros.
`handle!{ block }` would define a block to inline later when needed and then `check!` would do the normal thing but also inline that block, just like Go's.
Also, I feel like it is a little disingenuous to say that Rust has `no equivalent of handle` when it has something so similar in `Result::or_else(self, Op)`. You don't get the handle accumulation and you have to pass in a closure at the site, but they're remarkably similar.