use crate::{How, IntoContext}; pub trait Explain: Sized { type T; fn explained(self) -> Result; fn context(self, context: impl IntoContext) -> Result { self.explained() .context(context) } } impl Explain for Result where E: std::error::Error { type T = T; fn explained(self) -> Result { self.map_err(Into::into) } } impl Explain for Result { type T = T; fn explained(self) -> Result { self } #[inline(always)] fn context(self, context: impl IntoContext) -> Result { self.map_err(|e| e.context(context)) } }