Referencing workspace member as dependency

One can specify a workspace dependency and refer to it from a member crate with

# in root Cargo.toml
[workspace]
members = ["foo", "bar"]

[workspace.dependencies]
rand = "0.8"

# in foo crate
[dependencies]
rand = { workspace = true }

Is there a way I can refer to a member crate in the dependencies similarly. Currently, I just use path specifier, but if my directory structure changes it is a headache to fix.

Example

# in foo crate
[dependencies]
rand = { workspace = true }
bar = { workspace = true } # this would be nice!

Specify your path dependency in the workspace.dependencies table and then you can do exactly that. Doesn't save you from updating one entry for each crate that moved, but if lots of crates referred to it that's still an upgrade

1 Like

Perfect, thanks! I had not thought of doing that!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.