According to http://doc.crates.io/manifest.html#the-project-layout...
Cargo will also treat any files located in src/bin/*.rs as executables.
... which is presented as an invariant. There is no mention that this is conditional.
My project started out with with a few binaries src/bin/*.rs. When src/bin/daemon.rs ballooned, I refactored it into src/bin/daemon/main.rs and organized extracted code into modules under src/bin/daemon.
Once I added a [[bin]] entry to Cargo.toml, cargo build only builds the daemon binary, and no longer adheres to the quote above.
I see two options here:
-
Update the quoted portion of the manifest to indicate that *Cargo will treat any files located in /src/bin/*.rs as executables unless the toml contains a [[bin]] section.
-
Modify the behavior of cargo to comply with the docs. cargo treats any files located in src/bin/*.rs that are not otherwise defined in a [[bin]] section as executables.
a. cargo fetches list of binaries from src/bin/*.rs.
b. cargo replaces any binaries from src/bin/*.rs with respective [[bin]] entries found in toml.
c. cargo builds all executables in said list.
According to http://doc.crates.io/manifest.html#the-project-layout...
... which is presented as an invariant. There is no mention that this is conditional.
My project started out with with a few binaries
src/bin/*.rs. Whensrc/bin/daemon.rsballooned, I refactored it intosrc/bin/daemon/main.rsand organized extracted code into modules undersrc/bin/daemon.Once I added a
[[bin]]entry toCargo.toml,cargo buildonly builds the daemon binary, and no longer adheres to the quote above.I see two options here:
Update the quoted portion of the manifest to indicate that *Cargo will treat any files located in
/src/bin/*.rsas executables unless the toml contains a[[bin]]section.Modify the behavior of
cargoto comply with the docs.cargotreats any files located insrc/bin/*.rsthat are not otherwise defined in a[[bin]]section as executables.a.
cargofetches list of binaries fromsrc/bin/*.rs.b.
cargoreplaces any binaries fromsrc/bin/*.rswith respective[[bin]]entries found in toml.c.
cargobuilds all executables in said list.