您需要创建工作区:
Cargo.toml
[workspace]
members = [
"./<your-cargo-project1>",
"./<your-cargo-project2>",
]
我的解决方案是将所有
Cargo.toml
的相对路径添加到工作区中的 rust-analyzer.linkedProjects
设置(.vscode/settings.json
或 Ctrl+Shift+P > Preferences: Open Workspace Settings (JSON)
)。
{
"rust-analyzer.linkedProjects": [
"cargo-test/Cargo.toml",
"codecrafters-git-rust/Cargo.toml"
]
}
这有助于智能感知在这两个项目中发挥作用。