Rust 和 VSCode 中的新行中继续 Docstring

Erd*_*ray 1 rust visual-studio-code

考虑如下结构:

struct Foo;
Run Code Online (Sandbox Code Playgroud)

我想为此写一些文档,所以我这样做:

/// whatever
struct Foo;
Run Code Online (Sandbox Code Playgroud)

但是,当我按 Enter 时,它会创建一个空行:

/// whatever

struct Foo;
Run Code Online (Sandbox Code Playgroud)

不是在文档字符串中添加新行,而是///在其前面添加:

/// whatever
///
struct Foo;
Run Code Online (Sandbox Code Playgroud)

我已经六个月没有碰电脑或编程了。我记得六个月前我就能做到。也许是因为 6 个月前我有一个扩展(也许是 RLS?)调用了该行为,但现在没有。

如何在 Rust 和 VSCode 中以换行符继续文档字符串?


VSCode 和扩展

  • VSCode 1.53.0
  • Rust 扩展(包)0.0.3
  • 铁锈 0.7.8
  • Rust 分析仪 0.2.481

其他

  • rustc 和货物 1.49.0
  • rust-analyzer(由 Rust 分析器扩展提供)提交 336909b

Ibr*_*med 5

该功能确实存在于 rust-analyzer 中,但需要显式启用。要启用它,您需要将以下内容添加到您的keybindings.json

{
   "key": "Enter",
   "command": "rust-analyzer.onEnter",
   "when": "editorTextFocus && !suggestWidgetVisible && editorLangId == rust"
}
Run Code Online (Sandbox Code Playgroud)