4 ms·
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::er
by gsserge 6y ago
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-implement-error-regardless-whether-t-sized/48605 https://users.rust-lang.org/t/shouldnt-box-t-where-t-error-i...