Newcomer, you may want to skip this thread. Its idea was based on an untenable thesis. Thanks for the feedback!
Ok/Err wrapping is the number one benefit of try fn. You can easily return both success values and failures without conversions or wrapping.
Now, with rfc #1624 in stable Rust we can break loops with a value - without the need of labels.
let foo = loop {
break v;
};
Would it not be possible to make try {...} blocks similar to loop {...} blocks in this regard but also do automatic wrapping? You may then exit a try block by means of the ? operator, early exiting with break (success or failure), or by just ending the block with a success value.
try fns can be early returned from in the same manner.
What makes this design better?
-
No need for
throw/fail keywords: return/break have your back.
- Early success exits from
try blocks are possible. Just use break.
- The
try block/fn just introduces the fallibility semantics to the block or function, and makes the idea of errors (already present with the ? operator) a more pivotal notion in Rust, without much feature baggage.
Go ahead, shoot me down!