Result type

In functional programming, a result type is a monadic type holding a returned value or an error code. They provide an elegant way of handling errors, without resorting to exception handling; when a function that may fail returns a result type, the programmer is forced to consider success or failure paths, before getting access to the expected result; this eliminates the possibility of an erroneous programmer assumption.

Examples

 * In Elm, it is defined by the standard library as Err e.
 * In Haskell, by convention the Either type is used for this purpose, which is defined by the standard library as Right b, where a is the error type and b is the return type.
 * In Kotlin, it is defined by the standard library as value class Result.
 * In OCaml, it is defined by the standard library as Error of 'b type.
 * In Rust, it is defined by the standard library as enum Result { Ok(T), Err(E) }.
 * In Scala, the standard library also defines an Either type, however Scala also has more conventional exception handling.
 * In Swift, it is defined by the standard library as @frozen enum Result where Failure : Error.
 * In C++, it is defined by the standard library as std::expected.
 * In Python, it is available from third party libraries such as returns and result.

Rust
The result object has the methods  and.