This rust function is just tragic, clarity matters

preview_player
Показать описание
Let's make it better by using the power of the ? operator and traits!!

In Rust, error handling can sometimes be a bit cumbersome, especially when using pattern matching to handle errors. However, there are simpler ways to handle errors that can make your code more concise and readable.

In Rust, the ? operator is used to propagate errors in a concise way. It can be used in functions that return a Result or Option type to automatically return an error if the function call fails.

The ? operator is typically used after a function call that returns a Result or Option type.
Рекомендации по теме
Комментарии
Автор

have you ever planned to do a course in rust?, or have one already?

fartucu
Автор

What if u want to store error source location then u return Err? Like file!() line!() column!()? To, maybe, serialized it and send to another service?

kuqmua
Автор

How do you know what to do that looks complicated

michaelkondrashov