Skip to content

Instantly share code, notes, and snippets.

@alieniasty
Created January 29, 2020 19:31
Show Gist options
  • Save alieniasty/ad5e8d2b97e9884310712b33d33f4b28 to your computer and use it in GitHub Desktop.
Save alieniasty/ad5e8d2b97e9884310712b33d33f4b28 to your computer and use it in GitHub Desktop.
Option vs Result
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