diff options
author | bravomikekilo <[email protected]> | 2019-11-21 18:51:40 +0000 |
---|---|---|
committer | bravomikekilo <[email protected]> | 2019-11-21 18:51:40 +0000 |
commit | 8a8be062194604360bbb27ee11961b8a72973f44 (patch) | |
tree | 368cb308aed82b6d0e226b4fe769f75d69f9d743 /docs/user | |
parent | d0a9ed50da054d74721c6c51124696a20de5843b (diff) |
initial invert_if
Diffstat (limited to 'docs/user')
-rw-r--r-- | docs/user/assists.md | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/user/assists.md b/docs/user/assists.md index 8da7578e2..6e7811bd6 100644 --- a/docs/user/assists.md +++ b/docs/user/assists.md | |||
@@ -329,6 +329,25 @@ fn main() { | |||
329 | } | 329 | } |
330 | ``` | 330 | ``` |
331 | 331 | ||
332 | ## `invert_if` | ||
333 | |||
334 | Apply invert_if | ||
335 | This transforms if expressions of the form `if !x {A} else {B}` into `if x {B} else {A}` | ||
336 | This also works with `!=`. This assist can only be applied with the cursor | ||
337 | on `if`. | ||
338 | |||
339 | ```rust | ||
340 | // BEFORE | ||
341 | fn main() { | ||
342 | if┃ !y {A} else {B} | ||
343 | } | ||
344 | |||
345 | // AFTER | ||
346 | fn main() { | ||
347 | if y {B} else {A} | ||
348 | } | ||
349 | ``` | ||
350 | |||
332 | ## `make_raw_string` | 351 | ## `make_raw_string` |
333 | 352 | ||
334 | Adds `r#` to a plain string literal. | 353 | Adds `r#` to a plain string literal. |