如何在 VSCode 中导航到 Rust 源?

can*_*asp 6 rust visual-studio-code rust-analyzer

我有这样的代码:

#[derive(Debug)]
struct Rectangle {
    width: u32,
    height: u32,
}
Run Code Online (Sandbox Code Playgroud)

...我想深入了解Debug.

在 IntelliJ IDEA 中,我将光标放在上面Debug,然后按cmd + b导航到 Rust 源。

在 VSCode 中,我试图获得类似于 IDEA 中的行为:

  • 将光标放在同一位置(单词的中间Debug
  • 打开右键菜单
  • Go to definition (F12)Go to Implementations(cmd + F12)

VSCode 向我显示消息No definition found for 'Debug'

有没有办法像在IDEA中那样在VSCode中按源设置导航?

我在 VSCode 中使用这个 Rust 扩展

小智 5

您可以使用rust-analizer扩展来完成此操作,按住 ctrl 键并单击“调试”,它应该可以工作。如果您正在使用 Rust 扩展,我建议您反对它,因为它已被放弃。

  • 通过额外的支持信息可以改进您的答案。请[编辑]添加更多详细信息,例如引文或文档,以便其他人可以确认您的答案是正确的。您可以[在帮助中心](/help/how-to-answer)找到有关如何写出好的答案的更多信息。 (2认同)