Option and Result
Option Definition
Option
is a container type in rust which is used to represent a value which may or may not be present. The compiler will treat an Option value as schrodinger's cat, meaning it does not assume it's presence or absence. So as a programmer we need to instruct the compiler on what to do in each of the case.
How to use an Option
Pattern matching
Instruct what to do on either case
In case of missing value you can choose to terminate the program using panic!
macro or choose a defualt value.
Panics
Default behaviour
Result Definition
Last updated