Have you ever had an error that you just were so over that you wanted to yeet it back to the caller function? Maybe, say,
yeet e it?
This page to to track progress on the ability to yeet errors in Rust.
yeetas a reserved keyword
yeetkeyword early returning errors
yeet, after coming up with the idea in a conversation with Jane Lusby
Rust error handling can be verbose and clunky sometimes. There is a whole team dedicated to making it better.
One of the goals is to make it easier to propagate errors, so the idea is to add syntactic sugar for
This could be
bail e or any other number of keywords.
I could talk about how
throw exists in other languages,
bail is already used in many crates, but fundamentally, languages can be whatever we want them to be.
Words are not off limits just because they are slang, it is okay to have fun, and as a community we can come together and say yes to
Eh2406's Zulip message points out that at some point, "Ok" was considered slang for "Okay", but we have
So why not yeet our way into the future and add
yeet as a reserved word?
No, and it is probably for the best.
yeet is just a placeholder term to prevent bikeshedding and preventing progress on a legitimate (and very cool) feature, not a serious language proposal. And while I have talked extensively about the benefits of reserving it as a keyword on this page, it would prevent
yeet being used as an identifier, and
yeet is for the people. So while we are all having fun with
yeet, don't expect this page to change.