News for hackers. Stuff that matters.
Re:Rust Cookbook by gsserge on Thursday February 11, 2021 @10:10AM (#26102226)
One thing that is useful to keep in mind when considering boxed errors or error-like objects, e.g. anyhow::Error, is that they famously do not implement std::error::Error trait [1].

This could be a problem if you want to use a third-party API where generic functions or structs use std::error::Error in their trait bounds. For example, fn use_error<E: std::error::Error>(e: E) { ... } will not compile with a boxed error as the parameter.

[1] https://users.rust-lang.org/t/shouldnt-box-t-where-t-error-i...

There are no comments on this comment yet.