pub trait OrFail: Sized {
type Value;
type Error;
// Required methods
fn or_fail(self) -> Result<Self::Value>;
fn or_fail_with<F>(self, f: F) -> Result<Self::Value>
where F: FnOnce(Self::Error) -> String;
}Expand description
This trait allows for converting a value into Result<_, Failure>.
Required Associated Types§
Required Methods§
Sourcefn or_fail(self) -> Result<Self::Value>
fn or_fail(self) -> Result<Self::Value>
Returns Err(Failure) if self is a failure value.
If Err(_) is returned, this method should add the current caller location to the backtrace of the resulting Failure.
Sourcefn or_fail_with<F>(self, f: F) -> Result<Self::Value>
fn or_fail_with<F>(self, f: F) -> Result<Self::Value>
Like OrFail::or_fail(), but allows for customizing the Failure 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.