Support variables in `Cargo.toml`?

This is very useful, especially in the workspace scenario.

Just like java maven: Maven – Introduction to the POM

For example:

# Cargo.toml

members = ["foo", "bar"]

foo_name = "foo"
foo_version = "0.1.0"
# foo/Cargo.toml

name = "${foo_name}"
version = "${foo_version}"
# bar/Cargo.toml

name = "bar"
version = "0.1.0"

${foo_name} = { version = "${foo_version}", path = "../${foo_name}" }

The variable foo_name and foo_version can be shared between packages. Therefore, it is very convenient to modify.

1 Like

I known the workspace.package, but he is not flexible.

At least, my example can not be done with workspace.package.

This design has been rejected already, and Cargo decided to add workspace inheritance instead.