rust 嵌入提示和悬停信息在VSCode中不起作用[重复]

busg9geu  于 10个月前  发布在  Vscode
关注(0)|答案(1)|浏览(84)

此问题在此处已有答案

How can I build multiple binaries with Cargo?(3个答案)
12天前关门了。
我正在学习Rust,并在Linux上使用VSCode。我有这个项目:

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

字符串
嵌入提示和悬停信息在 * main.rs * 上可以正常工作,但在其他文件上不行,为什么?如果我有这样的结构,也会发生同样的情况

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

ej83mcc0

ej83mcc01#

如果你想要一个包含许多独立运行的程序的项目,它应该像这样布局:

.
├── src
│   └── bin
│       ├── 01_hello_world
│       │   ├── comm.rs
│       │   └── main.rs
│       └── 02_another_thing
│           └── main.rs
├── target
├── Cargo.lock
└── Cargo.toml

字符串

  • 每个程序(二进制目标)的根文件是src/bin/NAME/main.rs
  • 你可以像cargo run --bin 01_hello_world一样运行它们。
  • 不需要src/main.rs,但如果需要,可以创建一个src/lib.rs,其中包含它们中的任何一个都可以使用的代码。

相关问题