tinymist_std::error

Trait WithContext

Source
pub trait WithContext<T>: Sized {
    // Required methods
    fn context(self, loc: &'static str) -> Result<T>;
    fn with_context<F>(self, loc: &'static str, f: F) -> Result<T>
       where F: FnOnce() -> Option<Box<[(&'static str, String)]>>;
}
Expand description

A trait to add context to a result.

Required Methods§

Source

fn context(self, loc: &'static str) -> Result<T>

Add a context to the result.

Source

fn with_context<F>(self, loc: &'static str, f: F) -> Result<T>
where F: FnOnce() -> Option<Box<[(&'static str, String)]>>,

Add a context to the result with additional arguments.

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> WithContext<T> for Option<T>

Source§

fn context(self, loc: &'static str) -> Result<T>

Source§

fn with_context<F>(self, loc: &'static str, f: F) -> Result<T>
where F: FnOnce() -> Option<Box<[(&'static str, String)]>>,

Implementors§

Source§

impl<T, E: ErrKindExt> WithContext<T> for Result<T, E>