quick-error
quick-error copied to clipboard
Generic type arguments on errors.
I just discovered that this isn't possible:
quick_error! {
pub enum MyFancyError<E> {
Foo(e: E) { }
}
}
Which is a shame, because this would be very useful.
The error I'm wrapping has a lifetime parameter, so I would need this as well.
quick_error! {
pub enum MyError<'a> {
Foo(e: SomeError<'a>) { }
}
}
Well, unfortunately generic arguments almost impossible to implement in current macro system. At least not for arbitrary generic parameters. Waiting for stable libmacro to make this possible.
But with the lifetimes there is a second issue: according to docs most of functionality of Error is for 'static bound, so I'm not sure it's too useful. (I've used to think that Any was required for Error, but can't find any references to it, maybe it was recently changed)
I actually found a better way to represent my error that doesn't involve lifetimes, so this is not a blocker for me anymore.
Even basic support for generics would be of enormous benefit to me... is there any chance we could get this working? I tried fiddling with the code, but it's truly arcane to me. :)
@tailhook Are you aware of https://danielkeep.github.io/rust-parse-generics/doc/parse_macros/ ? This may make the job of adding support for generics a lot easier. And right now, I'd pay for generics support! :)
No, I'm not. Looks interesting. Does it work for stable rust?
Not sure, but I believe so. I got pointed to this by someone on IRC.
Here’s the GitHub: https://github.com/DanielKeep/rust-parse-generics
Let me know what you think.
On 10 Jul 2016, at 23:18, Paul Colomiets [email protected] wrote:
No, I'm not. Looks interesting. Does it work for stable rust?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tailhook/quick-error/issues/20#issuecomment-231614231, or mute the thread https://github.com/notifications/unsubscribe/AAEF3CQ0sAbGalkIDzpmIlhUbwKJgjq3ks5qUW-tgaJpZM4HjksI.