I'm developing a crate keepawake that has both a library crate and binary crate. Rust allows a single crate to have both a library and binary part, yet, a problem still remains, you can't easily declare binary only dependencies, see rust-lang/cargo#1982 (h????://github.com/rust-lang/cargo/issues/1982). This leads to the library crate carrying dependencies that it doesn't really use (e.g. clap
) which are troublesome for users of the library crate (segevfiner/keepawake-rs#3 (h????://github.com/segevfiner/keepawake-rs/issues/3)).
I'm not sure what's the best way to handle this until something better is implemented in Cargo. I found rust - How can I specify binary-only dependencies? - Stack Overflow, but I'm not sure which solution of the ones offered there is best. And should I choose to use a workspace, what should the name of the library crate and binary crate be (Is there a convention)? As that will require creating a crate solely for splitting those dependencies with an artificial name, e.g. keepawake-cli
.
Links mangled due to dumb forum software restriction.