I'd like to create a rust package with two binary crates and a library which contains the shared code. I know how do do this for a simple program by putting the source files for the binaries in a src/bin/
subdirectory (e.g. src/bin/firstbin.rs
and src/bin/secondbin.rs
) and the library code either in src/
or in src/lib/
.
However, if the binaries have a substantial amount of non-shared code which does not belong in the library, and I want to split their source into multiple files, I'm not sure of how to lay out the source files. I'm thinking something along the lines of having src/bin/firstbin/
for the files which belong only to the first binary, and src/bin/secondbin/
for the second binary. However, I'm not sure how to reference these files from firstbin.rs
and secondbin.rs
.
So is this the right approach and if so how do I reference the files? If not, what's the best layout?