rust-lang-deprecated / error-chain

Error boilerplate for Rust
Apache License 2.0
729 stars 111 forks source link

Implementing foreign links on generic errors #146

Open ayoshi opened 7 years ago

ayoshi commented 7 years ago

Hi.

Is there any way to accomplish this? For something like std::sync::PoisonError<T> for example.

Yamakaky commented 7 years ago

No, there is no polymorphism. You can foreign link PoinsonError<Thing> though for example.

ayoshi commented 7 years ago

Thank you, yes, that much I succeed to do. The problem arises when there is a generic error, especially with lifetime parameters.

I think it could be implemented with addiitional parametric macro implementation - but I worked around it, so I wouldn't be able to give it a try. On Mon, 24 Apr 2017 at 7:09 Yamakaky notifications@github.com wrote:

No, there is no polymorphism. You can foreign link PoinsonError though for example.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/brson/error-chain/issues/146#issuecomment-296520596, or mute the thread https://github.com/notifications/unsubscribe-auth/AAeZwBlSOUp5WyOV5Ybz5gdxC5QPmmH9ks5rzCB0gaJpZM4NFqWi .

jsgf commented 7 years ago

Is there a plan to implement this? It has come up a few times for me.

Yamakaky commented 7 years ago

Yeah, I know... If you have an idea of implementation, it's more than welcome ^^

Object905 commented 7 years ago

There is parse_generics_shim, which is macro from closed RFC, that allows parsing generics and where clause in macro, it's limited, but possible solution.