1

In rust, I'm building out a crate that has multiple executables in the src/bin folder. For example:

|- src
|   |- bin
|   |   |- app1.rs
|   |   |- app2.rs
|   |- lib.rs
|   |- other_shared_code.rs
|- Cargo.toml

Cargo manages this part all neatly, and I don't have to modify the Cargo.toml to make this work. However, is it possible to specify dependencies for a specific app? For instance, a console version and a GUI version (this is just an example, I have more specific reasons that do not need to be described).

AdmiralJonB
  • 2,038
  • 3
  • 23
  • 27
  • 2
    I think you can achieve this with [Option 2 mentioned here](https://stackoverflow.com/a/46017284/4593433) but I would not recommend it. Is there any reason why you don't want to use a [workspace](https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html)? Apart from that there is an open [Issue](https://github.com/rust-lang/cargo/issues/1982) about this feature. – frankenapps Feb 21 '22 at 17:38
  • Thanks @frankenapps, I was not aware of the specifics of workspaces, that link is very useful. The other stack overflow answer is also good - I was not able to find that in my searching. – AdmiralJonB Feb 21 '22 at 19:03
  • @frankenapps If you want to write up an answer you can do so and I'll accept, otherwise I'll close down the question. – AdmiralJonB Feb 21 '22 at 19:05
  • See also [Rust package with both a library and a binary?](https://stackoverflow.com/a/50402684/155423) – Shepmaster Feb 21 '22 at 19:39

0 Answers0