Skip to main content

OrFail

Trait OrFail 

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

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

Required Methods§

Source

fn or_fail(self) -> Result<T, TestError>

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

Source

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

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", so this trait is not object safe.

Implementations on Foreign Types§

Source§

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

Source§

fn or_fail(self) -> Result<T, TestError>

Source§

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

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>>, ) -> Result<T, TestError>

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) -> Result<T, TestError>

Implementors§