diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-09 20:16:28 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-09 20:16:28 +0100 |
commit | cc284dad30de4990516eeccf60f24e613fd78a2a (patch) | |
tree | ab1b62d318b44bec3706a30401d5b4213f8618a3 /docs | |
parent | 2fc2d4373b2c4e96bebf320a84270eee3afe34aa (diff) | |
parent | c5f8f3b1f423781e09bb5f63e33d772ee59fab77 (diff) |
Merge #1122
1122: Add explicit type assist. r=matklad a=marcogroppo
This assist can be used to specify the explicit type in let statements. For example `let num = 1;` becomes `let num: i32 = 1;`.
The assist is applicable only if the inferred type is fully known.
Co-authored-by: Marco Groppo <[email protected]>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/user/features.md | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/docs/user/features.md b/docs/user/features.md index 3ac99eef1..09a7f5a43 100644 --- a/docs/user/features.md +++ b/docs/user/features.md | |||
@@ -333,10 +333,40 @@ impl VariantData { | |||
333 | ```rust | 333 | ```rust |
334 | // before: | 334 | // before: |
335 | use algo:<|>:visitor::{Visitor, visit}; | 335 | use algo:<|>:visitor::{Visitor, visit}; |
336 | //after: | 336 | // after: |
337 | use algo::{<|>visitor::{Visitor, visit}}; | 337 | use algo::{<|>visitor::{Visitor, visit}}; |
338 | ``` | 338 | ``` |
339 | 339 | ||
340 | - Flip binary expression | ||
341 | |||
342 | ```rust | ||
343 | // before: | ||
344 | fn foo() { | ||
345 | if 1 <<|> 2 { | ||
346 | println!("Who would have thought?"); | ||
347 | } | ||
348 | } | ||
349 | // after: | ||
350 | fn foo() { | ||
351 | if 2 ><|> 1 { | ||
352 | println!("Who would have thought?"); | ||
353 | } | ||
354 | } | ||
355 | ``` | ||
356 | |||
357 | - Add explicit type | ||
358 | |||
359 | ```rust | ||
360 | // before: | ||
361 | fn foo() { | ||
362 | let t<|> = (&2, Some(1)); | ||
363 | } | ||
364 | // after: | ||
365 | fn foo() { | ||
366 | let t<|>: (&i32, Option<i32>) = (&2, Some(1)); | ||
367 | } | ||
368 | ``` | ||
369 | |||
340 | ### Magic Completions | 370 | ### Magic Completions |
341 | 371 | ||
342 | In addition to usual reference completion, rust-analyzer provides some ✨magic✨ | 372 | In addition to usual reference completion, rust-analyzer provides some ✨magic✨ |