I would like to generate multiple binaries using a lot of the same common code. If I write everything in src/main.rs
I can simply mark items at pub(crate)
and access the code without exporting it. However if I put the binary in src/bin/foo.rs
then I can not find a way to access this without marking everything pub
. I would not like to mark everything pub not only because I don't want others to depend on it but also because it renders visibility checking ineffective.
The only workaround I have found is to put the file inside of the src
directory then put a simple shim in bin/foo-bar.rs
that just calls my_crate::bin_foo_bar::main()
. This isn't very tidy and requires a bunch of overhead.