A new way of error handling in Rust

preview_player
Показать описание
In today's video I will cover a new Rust keyword called "yeet". I'll take you through what it is, how it works in practice and how it allows us to throw errors back to the caller.

Chapters:
0:00 Intro
1:20 What does yeet solved?
3:16 Will yeet reach stable Rust?
Рекомендации по теме
Комментарии
Автор

Now replace true/false with nocap/cap and unsafe with yolo. Then we have a true modern language.

TAINCER_
Автор

I'm really confused what the point is; if there is a good use case for yeet, the example in the video is certainly not a demonstration of one. The only difference between the original and the 'yeet' version is that Err is replaced with yeet! and it has one less 'return' keyword. This is definitely not what I would call a simplification. Just based on this video, I would have to vote against having this feature in stable.

yevgeniygrechka
Автор

I did an april fools double take after seeing the keyword was "yeet". I'm not entirely convinced of its brevity especially when one of the lines ended up being longer than if you were to just use Err.

horsemology
Автор

I think error handling, like it is now, with results and options by default is one of Rusts best things, it doesn't seem like keyword magic, it's just an enum, I don't think it's necessary to put an abstraction on these types.
If the intent is to have runtime exception handling with yeet then... No?
I hate error handling in other languages, it's like a dream in Rust

WERTBON
Автор

Don't add "yeet". It creates more syntax to an already complex language. It doesn't give any significiant advantage over return Err().

return Err() is boring, predictable, and doesn't surprise anyone. It is clear what it does.

doomguy
Автор

you can also use `Err(...)?`/`None?` for shorter syntax, basically does the same thing

vxl
Автор

I spent about 1 year and a half doing in Rust, and recently I worked in Golang for about 300 hours, I've improved myself how to code more readable and reliable, I recognized yeet syntax is completely useless feature.

김화겸-ye
Автор

i think that the feature all in all is useless
the return Err() and Err() make total sense to me and i dont think it should get replaced

doce
Автор

Is there other more complex examples where we can see some benefits of this approach? On the shown examples it is completely superfluous.

lucianobestia
Автор

Lol the way rust handles errors is the entire reason I love rust. Stuff like throw and catch are a disaster, keep it verbose and keep it freaking solid, rust is a language I can rely on, the more of this nonsese they add like yeet, the more it destroys the entire reason why anyone would use rust.

skywalker
Автор

Is that only me who dont understand, I mean why ? Doesnt *Err* do the job ?
I see no use in this yeet thing

lMINERl
Автор

You scared me! For one second I thought this was some serious feature with dev backing.

This is a silly idea and it’s completely unnecessary.

theondono
Автор

I still can't believe `yeet` is an actual thing in Rust. owo/uwu are valid words, according to Collins dictionary. Just saying if anyone's thinking of new keywords...

gogudelagaze
Автор

I hope it never leaves unstable stage and will be changed to something more RUSTY, and will sound better. Right now it looks stupid.

piotao
Автор

I agree not to use the 'throw' keyword as this implies some sort of separate call stack, just like async-await implies a different sequence of code execution.
But yeet does none of that. As mentioned by others, the simplification of code (or hidden execution order) just isn't there.
Still, nice to see efforts to come up with an alternative to exception throwing.

ErikBongers
Автор

this doesn't simplify the error handling process
this doesn't make the code look any less confusing
all it does is put a smile on my face

BlaqwD
Автор

Changing things for the sake of changing is what Gradle does, the good thing about FOSS is that anyone can fork it and not add weird new features

JorgetePanete
Автор

I think this keyword is absolutely unnecessary. It is not a big deal to write `return Err(..)` instead of `do yeet ..`. Adding more ways to do such simple things makes language more inconsistent

sat
Автор

It's either the example in this video or that yeet is completely redundant, using Option or Result already solves the same problem exactly the same way, so whats the point? If yeet would become helpful, the return type shouldn't change from f32 to Option or Result.

mmssus
Автор

The question mark combined with the result enum looked perfect to me. At one glance, we can see what calls can early exit, especially when highlighted in VSCode.

mathieucuny