Hi, could somebody please point me to documentation on catch keyword in current Rust?
I did find RFC 0243 but that did not enlighten me too much.. The RFC seems to be talking about implementation options and it doesn't seem clear which ones have been chosen..
catch doesn't seem to be mentioned in rust books either..
Background
There's an ongoing discussion on the internals and one of the suggestions there is
fn foo() -> T { catch { ... }} can be shortened to fn foo() -> T catch { ... }
but I'm really struggling to understand what that means..
Thx Steve, it seems catch isn't yet implemented on nightly even..
Should have checked in playground
It's still interesting to know the answer to my "Extra Question" above,
though you're probably not the right person to enquire that from
That's exactly the bit I do not understand
Wouldn't one still need to wrap code into Ok even inside a catch?
In fact the RFC itself says
Before stabilizing, we should determine whether we plan to make changes to
better align this feature with a possible do notation
(for example, by removing the implicit Ok at the end of a catch block)
Hmm... implicit?.. I think I get it now.. This catch works in tandem with ? I see..
Not sure I'm a big fan of that RFC then
I see how it can be useful..
But it will just take a lot of effort to settle this into my head
Catch is on nightly but in a slightly different form with do catch due to the fact that catch is not a keyword (yet) [please look at discussions around the epoch rfc]
I had a hard time reconciling that playground example (thanks for that by the way!) against the RFC until I spotted https://github.com/rust-lang/rust/issues/41414 - hopefully that saves a bit of headscratching for others .