4 ms·
I 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 `unwra
by rectang 5y ago
I 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.