3 ms·
No, it's just in this example. In idomatic rust you would write this probably: https://gist.github.com/mitsuhiko/1f37c1092bdf54ce4213 https://gist.github.com/m
by the_mitsuhiko 12y ago
No, it's just in this example. In idomatic rust you would write this probably: https://gist.github.com/mitsuhiko/1f37c1092bdf54ce4213 https://gist.github.com/mitsuhiko/1f37c1092bdf54ce4213
The `try!` macro unwraps the okay part of the expression and early returns the err part. The nice thing about the explicit results is that you will do the error handling. With Python you often do not know if an error might come.
- bsaul 12y agoOk, much better. At the risk of looking more like a java try/catch, is it possible to wrap multiple statements in a single try! clause ? Or at least have some way of saying " if there's any error in this block of code, simply stop execution and forward it to the calling statement"
- the_mitsuhiko 12y agoNo, but that's would also defeat the purpose. The idea of results is that you know from looking at the code what can fail. If you remove that information you might as well use exceptions.