Trait mango_v4::error::Contextable
source · pub trait Contextable {
// Required methods
fn context(self, c: impl Display) -> Self;
fn with_context<C, F>(self, c: F) -> Self
where C: Display,
F: FnOnce() -> C;
}
Required Methods§
sourcefn context(self, c: impl Display) -> Self
fn context(self, c: impl Display) -> Self
Add a context string c
to a Result or Error
Example: foo().context(“calling foo”)?;
sourcefn with_context<C, F>(self, c: F) -> Selfwhere
C: Display,
F: FnOnce() -> C,
fn with_context<C, F>(self, c: F) -> Selfwhere C: Display, F: FnOnce() -> C,
Like context()
, but evaluate the context string lazily
Use this if it’s expensive to generate, like a format!() call.