Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic type arguments on errors. #20

Open
canndrew opened this issue Feb 26, 2016 · 7 comments
Open

Generic type arguments on errors. #20

canndrew opened this issue Feb 26, 2016 · 7 comments

Comments

@canndrew
Copy link

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.

@crumblingstatue
Copy link

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>) { }
    }
}

@tailhook
Copy link
Owner

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)

@crumblingstatue
Copy link

I actually found a better way to represent my error that doesn't involve lifetimes, so this is not a blocker for me anymore.

@alexreg
Copy link

alexreg commented Jul 9, 2016

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. :)

@alexreg
Copy link

alexreg commented Jul 10, 2016

@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! :)

@tailhook
Copy link
Owner

No, I'm not. Looks interesting. Does it work for stable rust?

@alexreg
Copy link

alexreg commented Jul 10, 2016

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 notifications@github.com 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 #20 (comment), or mute the thread https://github.com/notifications/unsubscribe/AAEF3CQ0sAbGalkIDzpmIlhUbwKJgjq3ks5qUW-tgaJpZM4HjksI.

vthriller added a commit to vthriller/fullerene-bin that referenced this issue Mar 8, 2020
The reason is tailhook/quick-error#20
and DrawingAreaErrorKind<E> from plotters.

Why not error-chain: rust-lang-deprecated/error-chain#240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants