Skip to main content


Little #RustLang trivia for the crate `anyhow`:

if `FooError` and `BarError` are both error types, then you can do:

let wrapped = anyhow::anyhow!(FooError).context(BarError);

and `wrapped` will `downcast_ref` to both `FooError` and `BarError`.

Useful to inspect the context independently of the error! Just a bit unintuitive in my opinion.

docs.rs/anyhow/1.0.66/anyhow/t…