November 2017
Intermediate to advanced
264 pages
5h 45m
English
Here we look at two kinds of enum that are used everywhere in Rust code. A Result is a special kind of enum that is defined in the standard library. It is used whenever something is executed, that can either end:
Because this situation is so common, provision is made that the value T and error E types can be as general, or generic, as possible. The Result enum is defined as:
enum Result<T, E> {
Ok(T),
Err(E)
}
An Option is another enum that is defined in the standard library. It is used whenever there is a value, but there can also be a possibility that there is no value. For example, suppose our program ...
Read now
Unlock full access