result - [devnet]
Provides the Result<T, E> type, which allows to represent a success value T or an error value E.
Enum Result
Represents the result of some computation, either a value T or an error E.
enum Result<T, E> has copy, storeVariants
Ok
Fields
-
0: T
Err
Fields
-
0: E
Constants
Attempt to unwrap error but found value
const E_UNWRAP_ERR: u64 = 1;Attempt to unwrap value but found error
const E_UNWRAP_OK: u64 = 0;Functions
is_ok
Checks whether the result is Ok.
public fun is_ok<T, E>(self: &result::Result<T, E>): boolImplementation
public fun is_ok<T, E>(self: &Result<T, E>): bool { self is Ok}is_err
Checks whether the result is Err.
public fun is_err<T, E>(self: &result::Result<T, E>): boolImplementation
public fun is_err<T, E>(self: &Result<T, E>): bool { self is Err}unwrap
Unpacks the T of Ok or aborts.
public fun unwrap<T, E>(self: result::Result<T, E>): TImplementation
public fun unwrap<T, E>(self: Result<T, E>): T { match (self) { Ok(x) => x, _ => abort error::invalid_argument(E_UNWRAP_OK) }}unwrap_err
Unpacks the E of Err or aborts.
public fun unwrap_err<T, E>(self: result::Result<T, E>): EImplementation
public fun unwrap_err<T, E>(self: Result<T, E>): E { match (self) { Err(x) => x, _ => abort error::invalid_argument(E_UNWRAP_ERR) }}