pub trait OkOrNotFound {
type T;
// Required method
fn ok_or_not_found<B>(self) -> Result<Self::T, NotFoundError<B>>;
}Expand description
An extension trait for Option<T> to convert it to Result<T, NotFoundError<AnotherType>>
Useful in places where you need NotFoundError<AnotherType> instead of NotFoundError<T>.
§Examples
pub fn get_root(path: &Path) -> Result<&Path, NotFoundError<WorkspaceRoot>> {
find_root(path).ok_or_not_found()
}§See also
Required Associated Types§
Required Methods§
fn ok_or_not_found<B>(self) -> Result<Self::T, NotFoundError<B>>
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.