在VSCode中,嵌入提示和悬停信息无法正常工作。

huangapple go评论56阅读模式
英文:

Inlay hints and hover information not working in VSCode

问题

我正在学习Rust,我在Linux上使用VSCode。我有这个项目:

Inlay提示和悬停信息在main.rs上运行正常,但对于其他文件却不起作用,为什么?如果我有这个结构,情况也是一样的:

英文:

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

得分: 1

如果您想要一个包含许多可独立运行程序的项目,它应该按照以下方式布局:

.
├── 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
英文:

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.

huangapple
  • 本文由 发表于 2023年7月23日 16:55:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76747389.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定