unwrap abstract method

T unwrap()

Returns the contained Ok (success) value. Because this function may throw an exception, its use is generally discouraged. Instead, prefer to use switch statements with the Result.type and handle the Err (failure) case explicitly, or call `unwrapOr`, `unwrapOrElse`.

Throws an exception

Throws an exception if the value is an Err, with exception message provided by the Err's value.

Examples

Basic Usage:

Result<int, String> x = Ok(69);
expect(x.unwrap(), 69);

Result<int, String> y = Err('emergency failure');
expect(y.unwrap(), "emergency failure"); // Throws an exception with message `called `Result.unwrapErr()` on an `Err` value: 'emergency failure'`

Implementation

T unwrap();