Is it possible to have one crate with both procedural macros and logic?

Viewed 551

When you want to share a library that uses a procedural macro, is the dual crate approach foo/foo_derive inevitable?

I would like to provide a crate that has the logic and the macros. The first thing I tried was:

my_proc_macro
├── Cargo.toml
├── src/lib.rs
└── my_crate
    ├── Cargo.toml
    └── src/lib.rs

In the my_proc_macro crate, I tried to pub use my_crate::*; but it is forbidden to do so: the compiler refused to build this.

Is it possible to do this the other way around? I mean: import the procedural macro crate into the library and then reexport the macro?

1 Answers
Related