Skip to main content

OrFail

Trait OrFail 

Source
pub trait OrFail<T> {
    // Required methods
    fn or_fail(self) -> TestResult<T>;
    fn or_fail_with(
        self,
        message: impl Into<Cow<'static, str>>,
    ) -> TestResult<T>;
}
Expand description

Converts a fallible value into a TestResult, producing a TestError on the failure path.

Required Methods§

Source

fn or_fail(self) -> TestResult<T>

Converts the failure path into a TestError with a default message.

Source

fn or_fail_with(self, message: impl Into<Cow<'static, str>>) -> TestResult<T>

Like or_fail, but with a caller-supplied message.

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, E> OrFail<T> for Result<T, E>
where E: Error + Send + Sync + 'static,

Source§

fn or_fail_with(self, message: impl Into<Cow<'static, str>>) -> TestResult<T>

The supplied message is attached as a context frame, so the underlying error’s own message and source chain are preserved.

Source§

fn or_fail(self) -> TestResult<T>

Source§

impl<T> OrFail<T> for Option<T>

Source§

fn or_fail(self) -> TestResult<T>

Source§

fn or_fail_with(self, message: impl Into<Cow<'static, str>>) -> TestResult<T>

Implementors§