Function not_found_error::not_found

source ·
pub fn not_found<AnotherType>() -> NotFoundError<AnotherType>
Expand description

A shorter version of NotFoundError::new().

Useful in places where you need to convert Option<T> into Result<T, NotFoundError<AnotherType>> (notice that T != AnotherType).

§Examples

pub fn get_root(path: &Path) -> Result<&Path, NotFoundError<WorkspaceRoot>> {
     find_root(path).ok_or(not_found())
}

§See also

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