3 ms·
> options don't tell you why they failed Options aren't built into the language, they're just a standard library type that any user could define themselves, an
by kibwen 13y ago
> options don't tell you why they failed
Options aren't built into the language, they're just a standard library type that any user could define themselves, and we don't recommend them as a replacement for robust error handling anyway. For that we have the Result type, another type that's defined in the standard library, which does indeed contain an error message.
> you have to know what match does,
> what this magic (None) => business is...
`match` is just a beefed-up switch statement. And `None` is, to reiterate, an essential component of the standard library, and not magical in any way.
Your Rust code also shows that you've never actually used it before. Here's a proper translation of the Go code into Rust:
let result = foo();
if result.is_err() {
return result;
}