pub trait Context<T, E: StdError> {
// Required method
fn context(self, context: &str, hint: Option<&str>) -> Result<T>;
}Expand description
Trait for adding context and an optional hint to errors.
§example:
use idc::*;
use std::fs;
fn main() -> Result<()> {
let foo = fs::read_to_string("foo").context("failed to read foo.", "maybe it doesn't exist?".into())?;
println!("{}", foo);
Ok(())
}