derive_more icon indicating copy to clipboard operation
derive_more copied to clipboard

Specifying the error type for TryFrom implementations

Open tpoliaw opened this issue 9 months ago • 0 comments
trafficstars

Would it be possible to allow users to specify the error type returned from TryFrom implementations? Something like

#[derive(From)]
struct UnknownMode(u8);

#[derive(TryFrom)]
#[try_from(repr, error = UnknownMode)]
#[repr(u8)]
enum Mode {
    Foo,
    Bar,
}

where the given error has to implement From<T> where T is the type for which TryFrom<T> is being implemented.

tpoliaw avatar Feb 15 '25 19:02 tpoliaw