Cargo workspaces, inheriting and publishing

Am I correct in assuming that using workspace inheritance is pretty much useless for crates that one wants to publish on crates.io?

If I understand it correctly, publishing will never rewrite a crate's Cargo.toml, so it can't replace pcap = { workspace = true } with pcap = { version = "2.2.0" }?

Is it too strong of a statement to say that workspace inheritance are for non-published projects only?

1 Like

When you run cargo publish, Cargo generates a new crates.io-compatible Cargo.toml for the crate it publishes. The new file will have path and workspace dependencies rewritten to standalone crates.io dependencies.

2 Likes

Amazing -- this makes workspaces like 10x more convenient than I thought.

This is why if you look at the contents of a published package, you will see two files, Cargo.toml and Cargo.toml.orig; the latter is the original copy before rewriting.

2 Likes