Trait not_found_error::OkOrNotFound

source ·
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

  • Require: Trait for converting Option<T> to Result<T, NotFoundError<T>>
  • require: Function to convert Option<T> to Result<T, NotFoundError<T>>

Required Associated Types§

source

type T

Required Methods§

source

fn ok_or_not_found<B>(self) -> Result<Self::T, NotFoundError<B>>

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> OkOrNotFound for Option<T>

§

type T = T

source§

fn ok_or_not_found<B>(self) -> Result<Self::T, NotFoundError<B>>

Implementors§