|
|
|
|
|
by icod
1936 days ago
|
|
to this day I can't wrap my head around the need to unwrap almost every single variable/function/whatever. I don't get Rust. I got Go very easily.
Rust just doesn't make sense for me. In Go I can just write down my thoughts and they translate to code easy.
I don't even know which mental game I have to play in Rust. And all the conventions in Rust are another step.
The final nail is the un-community of Rust.
I still have no idea how to write a simple RESTful http server with a mongodb backend. I've asked only to have been met with downvotes on Reddit. The official MongoDB discourse didn't answer either. Time and again I want to do something with it but every time I just quit frustrated and irritated of the complexity of everything in Rust land. |
|
Think of Result as (foo, err) bundled into one thing. result.unwrap() is then equivalent to:
And the ? operator is: You don't need to unwrap (or ?) everything, just things that return a Result -- which is the same as functions which return an error in Go. The advantage of Result is that you can never forget to handle the error because the compiler requires you to get the value out of the Result in such a way that you have to handle errors.Don't get me wrong, there are complicated things in Rust, I just don't see how Result-based error handling is one of them. This is also not a new idea, many languages have something similar.