Derive support for From implementations
Opened this issue · 5 comments
Oftentimes, a custom error is an enum with variants, some of which are just wrappers around some foreign errors/causes.
The derive machinery allows for marking the field as #[cause]
, like this:
https://boats.gitlab.io/failure/derive-fail.html#overriding-cause
Would it make sense to add possibility to also derive From
for such a newtype-style variant, eg by adding #[from]
attribute to it?
I would like this, too. I accept the points made in the old discussion regarding context, but often I am implementing a simple parser with only a single I/O operation in the whole file (reading the next line), and I want to capture the io::Error
in my error enum so I can use ?
cleanly.
It would be that much smoother of an experience if I could just add #[from]
and keep focusing on the happy path of this fairly simple code.
@withoutboats Any new thoughts on this? Adding the from
attribute as discussed previously seems to be widely desirable, and not too difficult, no? It doesn't get in the way of any existing design principles either.
I'm no longer actively involved in maintaining this library, not the correct person to ping. :)
@withoutboats Ah my bad; I wasn't aware.