derive_more
derive_more copied to clipboard
open for a IntoBox derive?
trafficstars
It would be great to have a simple derive for Boxed newtypes to just use <MyError>.into with:
#[derive(IntoBox)]
struct BoxedError(Box<MyError>);
The specific use case is that with thiserror its easy to compose complex error types and if one inner error exceeds a certain size you naturally want to Box only that one instead of making the whole compound error type boxed, now you have to write a custom From.
This comes up a lot in thiserror:
- https://github.com/dtolnay/thiserror/issues/57
- https://github.com/dtolnay/thiserror/issues/90
- https://github.com/dtolnay/thiserror/issues/302
- https://github.com/dtolnay/thiserror/issues/415
and it keeps referencing this crate for a solution wich it does not currently supply (to my knowledge). Would you be open for such a IntoBox (or FromInner, I am open regarding the naming)?