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§
Sourcefn or_fail(self) -> TestResult<T>
fn or_fail(self) -> TestResult<T>
Converts the failure path into a TestError with a default message.
Sourcefn or_fail_with(self, message: impl Into<Cow<'static, str>>) -> TestResult<T>
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", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<T> OrFail<T> for Option<T>
impl<T> OrFail<T> for Option<T>
fn or_fail(self) -> TestResult<T>
fn or_fail_with(self, message: impl Into<Cow<'static, str>>) -> TestResult<T>
Source§impl<T, E> OrFail<T> for Result<T, E>
impl<T, E> OrFail<T> for Result<T, E>
Source§fn or_fail_with(self, message: impl Into<Cow<'static, str>>) -> TestResult<T>
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.