Warning
This post was published 46 days ago. The information described in this article may have changed.
Let's say I have a crate that provides a derive macro:
#[derive(crate1::Foo)]
#[foo_param(blah)]
struct WantsFoo;
can I (in a separate crate) provide a derive macro that just delegates to the first one? e.g. I'd like this:
#[derive(crate2::FooBlah)]
struct WantsFoo;
to expand to the original definition.
The use case is to provide a special case ergonomic wrapper around the original (flexible and generic) functionality. I understand I can create a helper crate with ~all the logic from crate1::Foo
and share that between two unrelated macros, but ideally, I'd achieve this without touching crate1
(no real reason it should know about crate2
and go out of its way to help it).
4 posts - 2 participants
🏷️ rust_feed