Rust Result And Option. You use Option when you have a value that might exist or might not exist. I should say that Im familiar with the concepts of Option and ResultEither from other languages.
We will start with Option. Option is for functions that may or may not return a value say a string search may find something or may not find something. We understand enums and generics now so we can understand Option and Result.
You use Option when you have a value that might exist or might not exist.
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. If you have spent any amount of time learning Rust you quickly become accustomed to Option and Result types. Instantly share code notes and snippets. Option and Result types from Rust in TypeScript.