hobofan / ambassador

Delegation of trait implementations via procedural macros
Apache License 2.0
245 stars 13 forks source link

Allow delegatable trait to be defined in a different module than the `derive(Delegate)` #18

Closed thomaseizinger closed 4 years ago

thomaseizinger commented 4 years ago

It seems like ambassador is currently limited to delegation of traits that are defined within the same module.

We have a Facade in our code that could make good use of derive(Delegate) but the traits it implements are spread out over the code-base.

I guess delegatable_trait_remote could work here but it would require us to redefine all the traits even though they are actually not remote.

Any ideas?

hobofan commented 4 years ago

Hmm, that sounds strange. This test case should ensure that it's working: https://github.com/hobofan/ambassador/blob/5b0167ead06b0ead090371a3fc33f3fa39448c13/ambassador/tests/run-pass/derive_in_module.rs

Could you give me some more pointers to reproduce? Which traits you are trying to derive in you codebase, where it fails?

thomaseizinger commented 4 years ago

That is good to know, I'll have a another try tomorrow at work :)

Thanks for the quick support!

thomaseizinger commented 4 years ago

It does work!

What I forgot was to add #[macro_use] to the module where the original trait is defined :)