Workspace-centric `cargo add/remove`?

⚓ Rust    📅 2025-06-20    👤 surdeus    👁️ 6      

surdeus

Warning

This post was published 54 days ago. The information described in this article may have changed.

Gradually warming up to the concept of a workspace.

cargo new --lib inner_crate has got to be my new favourite thing to type.

Alas, there doesn't appear to be a simple way to add/remove an inner workspace member from the list of dependencies. Unless I'm missing something obvious? To clarify: is there a

  • cargo new --lib inner [--workspace/--dep]? - to
    • (a) create an inner folder
    • (b) add it in workspace.members of Cargo.toml
    • (c) add it as inner = { path = "./inner" } into workspace.dependencies
  • cargo remove inner [--workspace/--dep]? - to
    • (a) delete the same folder from the drive
    • (b) remove it from workspace.members and .dependencies

Or anything like it built-in and shipped with cargo?


Side question: it doesn't seem possible to have the name of the inner in the dependencies of the workspace itself be different from the path and/or (?) its own package.name - any idea why?

1 post - 1 participant

Read full topic

🏷️ rust_feed