October 2018
Beginner
180 pages
4h 48m
English
You may have noticed already, but the Result type with its Ok and Err values looks an awful lot like an enumeration. That's because it is an enumeration, which is how it's able to contain different data types depending on whether it represents an error or a success. It's an enumeration with generic type parameters, so we won't be able to pull off quite the same functionality until we learn about those but, at its base, it's still just an enumeration.
We can use Ok and Err instead of Result::Ok and Result::Err when we write functions that might fail or handle the results of such functions, because those values are added directly to the Rust prelude for our convenience. Actually, we can use ...
Read now
Unlock full access