cargo-expand
cargo-expand copied to clipboard
Expand only macros that come from a specific crate
Would be good to be able to only expand specific macros and leave other source as is.
i.e.: cargo expand --crate="my-crate-derive"
or cargo expand --derive=MyTraitA,MyTraitB
at the very least would be good to not expand macros that come from std.
This would be a game-changer, because it would allow you to use cargo-expand to "inline" utility macros like thiserror.
Right now a lot of manual effort is required to do this, because you either have to reimplement the macro functionality in plain code yourself or, if you're using cargo-expand, go through all the expanded stdlib macros (println!
and family) and un-expand them.
So yeah, that would be pretty damn cool and make this tool like, at least twice more useful
I would accept a PR to implement this.
This would be incredible! When developing macros I have to fix up all the expanded panics, format!'s, etc. It would be great if I could only expand a specific macro.
$ cargo expand utils::some_util --macro tokio::main