0

I'm learning Rust and I'm using VSCode on Linux. I have this project:

.
├── src
│   ├── 01_hello_world
│   │   ├── comm.rs
│   │   └── mod.rs
│   └── main.rs
├── target
├── Cargo.lock
└── Cargo.toml

Inlay hints and hover information work fine on main.rs but not for the other files, why? The same occurs if I have this structure

...
│   ├── 01_hello_world
│   │   ├── comments
│   │   │   └── mod.rs
│   │   └── mod.rs
...

1 Answers1

1

If you want a project with many independently runnable programs, it should be laid out like this:

.
├── src
│   └── bin
│       ├── 01_hello_world
│       │   ├── comm.rs
│       │   └── main.rs
│       └── 02_another_thing
│           └── main.rs
├── target
├── Cargo.lock
└── Cargo.toml
  • Each program's (binary target's) root file is src/bin/NAME/main.rs.
  • You run them like cargo run --bin 01_hello_world.
  • There is no need for a src/main.rs, but if you want, you can create a src/lib.rs that contains code that any of them can use.
Kevin Reid
  • 37,492
  • 13
  • 80
  • 108