Shared lib between two example binaries

I'm creating a project (a lib) for communicating over a bus-like system. In the project I have two example binaries, a producer and a consumer.

├── consumer
│   └──
├── common
│   └──
└── producer

Is there any way I can make the "common" lib a library that is shared between consumer and producer?

To be clear, "common" is just a lib for the examples.

You can't make it an actual library (Cargo will only build one library crate per package), but you could import it as a module into each binary. In both consumer/ and producer/, add this:

#[path = "../common/"]
mod common;

The main downside compared to a "real" library is that the code in common will be compiled twice (once for each binary).


that will work perfectly for me!

Thank you!