3 ms·
The Result type is specifically designed to store value-or-error. One may use it diffently but that’s what it’s made for. The library designers had a choice b
by ymbeld 6y ago
The Result type is specifically designed to store value-or-error. One may use it diffently but that’s what it’s made for.
The library designers had a choice between making a generic this-or-that type or a value-or-error type and they chose the latter because they thought that that would be the common this-or-that use-case.
Even Haskell’s more generic-sounding “Either” type is made for the same purpose: the “right” (as in correct) variant is the value while the left side is the error, by convention.
- Kaze404 6y agoI don't understand what the problem is, in that case. Is it just the fact that it's called an Error instead of something more generic? Not trying to sound dismissive, just trying to understand if there's something I'm missing.
- deleted 6y ago[deleted]
- zanellato19 6y agoWhile Result is designed for that, it was built with an Enum (see here: https://doc.rust-lang.org/src/core/result.rs.html#241-251 https://doc.rust-lang.org/src/core/result.rs.html#241-251) So you can also build an enum that doesn't have any explicit mention of which is the right path