Recoverable errors with
Ok variant indicates the operation was successful, and inside
Ok is the successfully generated value.
Err variant means the operation failed, and
Err contains information about how or why the operation failed.
- Catch-all error
Under the hood, the
From::fromon the error value to convert it to a boxed trait object, a
Box<dyn error::Error>. This boxed trait object is polymorphic, and since all errors implement the
error:Errortrait, we can capture lots of different errors in one “Box” object.
expect method can be used in
Result to provide user-defined message when in case of panic
At this point, a
Err(_) value is a programming error and the program is unable to recover from it.