Skip to main content

OrThrow

Trait OrThrow 

Source
pub trait OrThrow<T> {
    // Required method
    fn or_throw<E: Exn>(self, exn: E) -> T;
}
Expand description

Extension trait for replacing an error with a contract exception.

Required Methods§

Source

fn or_throw<E: Exn>(self, exn: E) -> T

On Err, throw exn as a contract exception. On Ok, return the value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, Err> OrThrow<T> for Result<T, Err>

Source§

fn or_throw<E: Exn>(self, exn: E) -> T

Source§

impl<T> OrThrow<T> for Option<T>

Source§

fn or_throw<E: Exn>(self, exn: E) -> T

Implementors§