The Cargo documentation for The dependencies table gives the following example:
# [PROJECT_DIR]/Cargo.toml
[workspace]
members = ["bar"]
[workspace.dependencies]
cc = "1.0.73"
rand = "0.8.5"
regex = { version = "1.6.0", default-features = false, features = ["std"] }
# [PROJECT_DIR]/bar/Cargo.toml
[package]
name = "bar"
version = "0.2.0"
[dependencies]
regex = { workspace = true, features = ["unicode"] }
[build-dependencies]
cc.workspace = true
[dev-dependencies]
rand.workspace = true
I am trying to implement using a dependencies table now for a project. I can't get the the rand.workspace = true
syntax to work for me. I can only get the following syntax to work:
# [PROJECT_DIR]/Cargo.toml
[workspace]
members = ["bar"]
[workspace.dependencies]
cc = "1.0.73"
rand = "0.8.5"
regex = { version = "1.6.0", default-features = false, features = ["std"] }
# [PROJECT_DIR]/bar/Cargo.toml
[package]
name = "bar"
version = "0.2.0"
[dependencies]
regex = { workspace = true, features = ["unicode"] }
[build-dependencies]
cc = { workspace = true }
[dev-dependencies]
rand = { workspace = true }
Can anybody help?
Update
After @cafe25 confirmed this all works for them I checked and my program compiles with the syntax I was saying I couldn't get to work. I just get an error that appears related to VSCode:
Errors
async-graphql-poem.workspace: Error: Command failed: git --no-pager --git-dir="../.cargo/registry/index/github.com-1ecc6299db9ec823/.git" show origin/HEAD:as/yn/async-graphql-poem.workspace
fatal: path 'as/yn/async-graphql-poem.workspace' does not exist in 'origin/HEAD'
This appears to be an issue with the crates extension for VSCode.