VSCode, big source tree, multiple rust cargo projects?

I'm a Rust beginner, and I'm trying to use VS Code. The way I've been using VS Code with C++ and other languages is that I open a single big monorepo directory containing multiple projects. Following the first chapters of the Rust Book, I ran: cargo new my_project. But VS Code and the rust-analyzer extension don't pick it up because it's a few levels down in the directory tree that I have open in VS Code. Is there a way to make that work, or do I have to open VS code directly on that directory created by cargo new?

You can set the setting rust-analyzer.linkedProjects to a list of the paths to the Cargo.toml files of each Rust project within the tree.

You may find you want to use separate VS Code workspaces to have separate settings and to not index/build all the projects at once, though.

2 Likes