mcmah309 / error_set

Ergonomic and precise error handling provided by error sets. Inspired by Zig's error set type.
Apache License 2.0
124 stars 2 forks source link

feature request: generics support #15

Open Easyoakland opened 2 weeks ago

Easyoakland commented 2 weeks ago

Thanks for the crate! I was skeptical before trying, but now I think I won't be using thiserror again.

It appears error_set! doesn't support generics. e.g.

error_set::error_set! {
    Error<E> = {
        Error1,
        Error2,
        Other(E)
    };
}

would this be possible to add?

mcmah309 commented 2 weeks ago

Of course!

Yes definitely possible. Shouldn't be too difficult either. where clauses should be supported as well.

Although E in your example would have to be specified to implement the Error trait. Since all wrapped types are considered source errors. But

Other {
    field: E
}

would not.

Thanks for submitting this issue.