pub trait FlattenCtxExt<T>: Sized {
// Required methods
fn flatten_ctx(self, context: &'static str) -> Result<T>;
fn flatten_ctx_with(self, context: String) -> Result<T>;
}Expand description
Substrate extension trait over anyhow::Result<T> — the ONE
substrate owner of the .map_err(|e| anyhow::anyhow!("<ctx>: {e}"))
display-prefix wrap-shape for consumers whose source error is
already anyhow::Error. See the module docs for the full callsite
audit + the naming rationale (why flatten_ctx and not
anyhow::Context::context).
Required Methods§
Sourcefn flatten_ctx(self, context: &'static str) -> Result<T>
fn flatten_ctx(self, context: &'static str) -> Result<T>
Wrap the source anyhow::Error (if any) with a static
context prefix, producing an anyhow::Result whose error
Display reads exactly "<context>: <source display>".
Sourcefn flatten_ctx_with(self, context: String) -> Result<T>
fn flatten_ctx_with(self, context: String) -> Result<T>
Owned-string peer of Self::flatten_ctx — the escape hatch
for consumers that compose the context slug via format!
(e.g. format!("evaluate {:?}", c.kind) where the tail is
only known at runtime).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".