3 ms·
> And unlike Go or C, I don't have to remember to check the error every single time. How do you mean? I’ve been writing Rust frequently lately and you still ha
by ViViDboarder 5y ago
> And unlike Go or C, I don't have to remember to check the error every single time.
How do you mean? I’ve been writing Rust frequently lately and you still have to check the case. Do you mean that the compiler will nag you if you stunt so you don’t have to remember to do it because you’ll be reminded?
That’s one of the things common Go linters do that I wish was built into the compiler. It’s silly that an unused dependency is a compiler error but an unchecked error/return value is not.
- rectang 5y agoI mean that in Rust, you have to work kinda hard to drop an error on the floor and leave it unhandled. It's easy and idiomatic to write code which calls `unwrap`, so that's what everybody does when they don't want or need to write sophisticated error handling code. But that's not the same as forgetting to check a return value — when something goes wrong, `unwrap` panics. I mean, if you're determined you can definitely drop an error in Rust, e.g. with a `match` arm that does nothing. But the easy path is to `unwrap`.
- JeremyNT 5y agoI learned rust before go and I was shocked by the (lack of) error handling in go. unwrap feels lazy, but it's obvious what is doing and it's impossible to do nothing. With go error handling is entirely optional.