|
|
|
|
|
by masklinn
2196 days ago
|
|
> If the implementation uses the optional type, it'll become impossible to write code that uses the zeroed-out returned value incorrectly. Since Go doesn't have sum types, it would most likely be possible: the option type would just be a reification of the MRV. At best it could panic if you try to get the value of an "empty" optional but now you've got a panic. |
|
What it does is preventing the accidental use of a missing value. You can’t pass the Option<T> on to a function taking a T without explicitly doing it.