Created
January 29, 2020 19:31
-
-
Save alieniasty/ad5e8d2b97e9884310712b33d33f4b28 to your computer and use it in GitHub Desktop.
Option vs Result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I think it's quite easy.. Option is for functions that may or may not return a value (say, a string search may find something or may not find something). So, both return values are valid and expected in your program. | |
Result, as is is shown by the Err enum, is for functions that are expected to succeed (thus, Ok()), but may fail and this has to be catched. Example: Opening a connection to some other server would generally be expected to work but of course can fail. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment