Re-exporting a trait with a custom derive_macro
⚓ Rust 📅 2026-04-24 👤 surdeus 👁️ 2I'm writing a library that uses trait Bar from crate foo. I'm trying to re-export Bar in my crate, so users can use my library without adding foo to their cargo.toml.
Unfortunatlely, the derive macro for the trait uses the fully qualified path ::foo::Bar, so to derive it the user still needs to add the dependency.
I have written a new derive macro that uses ::my_library::Bar instead, but now I cannot export it, because the name conflicts with the original macro.
Is there a standard way to approach this problem, or are my users forced to depend on the other crate to use the trait?
2 posts - 2 participants
🏷️ Rust_feed