pub trait UnwrapOrRevert<T> {
    // Required methods
    fn unwrap_or_revert(self) -> T;
    fn unwrap_or_revert_with<E: Into<ApiError>>(self, error: E) -> T;
}
Expand description

A trait which provides syntactic sugar for unwrapping a type or calling runtime::revert if this fails. It is implemented for Result and Option.

Required Methods§

source

fn unwrap_or_revert(self) -> T

Unwraps the value into its inner type or calls runtime::revert with a predetermined error code on failure.

source

fn unwrap_or_revert_with<E: Into<ApiError>>(self, error: E) -> T

Unwraps the value into its inner type or calls runtime::revert with the provided error on failure.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> UnwrapOrRevert<T> for Option<T>

source§

fn unwrap_or_revert(self) -> T

source§

fn unwrap_or_revert_with<E: Into<ApiError>>(self, error: E) -> T

source§

impl<T, E: Into<ApiError>> UnwrapOrRevert<T> for Result<T, E>

source§

fn unwrap_or_revert(self) -> T

source§

fn unwrap_or_revert_with<F: Into<ApiError>>(self, error: F) -> T

Implementors§