mirror of
https://github.com/rust-lang/rust.git
synced 2026-03-19 14:08:50 +00:00
auto-generate assists docs and tests
This commit is contained in:
24
docs/user/assists.md
Normal file
24
docs/user/assists.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Assists
|
||||
|
||||
## `convert_to_guarded_return`
|
||||
|
||||
Replace a large conditional with a guarded return.
|
||||
|
||||
```rust
|
||||
// BEFORE
|
||||
fn main() {
|
||||
<|>if cond {
|
||||
foo();
|
||||
bar();
|
||||
}
|
||||
}
|
||||
|
||||
// AFTER
|
||||
fn main() {
|
||||
if !cond {
|
||||
return;
|
||||
}
|
||||
foo();
|
||||
bar();
|
||||
}
|
||||
```
|
||||
@@ -97,11 +97,13 @@ Start `cargo watch` for live error highlighting. Will prompt to install if it's
|
||||
|
||||
Stop `cargo watch`
|
||||
|
||||
### Code Actions (Assists)
|
||||
### Assists (Code Actions)
|
||||
|
||||
These are triggered in a particular context via light bulb. We use custom code on
|
||||
the VS Code side to be able to position cursor. `<|>` signifies cursor
|
||||
|
||||
See [assists.md](./assists.md)
|
||||
|
||||
- Add `#[derive]`
|
||||
|
||||
```rust
|
||||
|
||||
Reference in New Issue
Block a user