Allow convert T into Ok(T)

We have nightly do yeet syntax that allows early-returning the residual from a try block, emulated via fehler's throw! macro.

2 Likes

I have no words to describe my feelings... It looks terrible. I just hope that this will be removed from Rust

IMO do yeet looks beautiful and Rust-compliant, although it's almost as verbose as return Err(...);... (four characters less)

BTW fn f() try is not still a nightly feature? There is only fn f() { try {} } for now.

These are highly experimental, thus the placeholder syntax.

This is not how it's intended to be stabilized, it's using the pre-reserved do keyword that has been used for other experimental syntax along with an obviously to-be-bikeshedded contextual keyword yeet to describe the operation. It's just implemented to allow exploring the semantics. The eventual syntax will likely use a direct keyword like throw err;, with an edition change to allow reserving a new keyword for it.

6 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.