3 ms·
Note that Rust now also has the ? operator, which can be a bit easier on the eyes than try!: https://github.com/rust-lang/rfcs/blob/master/text/0243-trait-base
by danieldk 10y ago
Note that Rust now also has the ? operator, which can be a bit easier on the eyes than try!:
https://github.com/rust-lang/rfcs/blob/master/text/0243-trait-based-exception-handling.md https://github.com/rust-lang/rfcs/blob/master/text/0243-trai...
https://blog.rust-lang.org/2016/11/10/Rust-1.13.html https://blog.rust-lang.org/2016/11/10/Rust-1.13.html
- saurik 10y agoFWIW, C++ has this really cool feature they call "exceptions", which is a language-level implementation of Result, try!, and ? that is automatically included as part of any function that would otherwise have to manually unwrap and pass along an error in languages like Rust; a really great bonus is that because the compiler has implemented this feature and abstracted it from the developer, in addition to it removing a lot of boilerplate from your code, it allows for an extremely fast table-based implementation they call "zero-cost exceptions" that can almost always completely eliminate the CPU cost of having to constantly check and forward error information.
- kaoD 10y ago> really cool feature Arguable.
- izym 10y agoYes, people are quite aware of that, and if you check the comments you'll see points made against it. Also, ? is very much language level.
- kibwen 10y agoCondescending sarcasm is unwarranted. People are well aware of what exceptions are, and the arguments against them amount to more than just performance.
- sidlls 10y agoI've implemented a Result-like error code construct in plenty of C++ projects and disabled exceptions precisely because I don't think they're a good way of handling error states in code.