mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
add feature doc
This commit is contained in:
parent
08e954f0fd
commit
079ed6011a
1 changed files with 31 additions and 2 deletions
|
@ -390,14 +390,14 @@ fn foo() {
|
||||||
|
|
||||||
- Move guard expression to match arm body
|
- Move guard expression to match arm body
|
||||||
```rust
|
```rust
|
||||||
//before:
|
// before:
|
||||||
fn f() {
|
fn f() {
|
||||||
match x {
|
match x {
|
||||||
<|>y @ 4 | y @ 5 if y > 5 => true,
|
<|>y @ 4 | y @ 5 if y > 5 => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//after:
|
// after:
|
||||||
fn f() {
|
fn f() {
|
||||||
match x {
|
match x {
|
||||||
y @ 4 | y @ 5 => if y > 5 { <|>true },
|
y @ 4 | y @ 5 => if y > 5 { <|>true },
|
||||||
|
@ -406,6 +406,35 @@ fn f() {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- Move if condition to match arm guard
|
||||||
|
```rust
|
||||||
|
// before:
|
||||||
|
fn f() {
|
||||||
|
let mut t = 'a';
|
||||||
|
let chars = "abcd";
|
||||||
|
match t {
|
||||||
|
'\r' => if chars.clone().next().is_some() {
|
||||||
|
t = 'e';<|>
|
||||||
|
false
|
||||||
|
},
|
||||||
|
_ => true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// after:
|
||||||
|
fn f() {
|
||||||
|
let mut t = 'a';
|
||||||
|
let chars = "abcd";
|
||||||
|
match t {
|
||||||
|
'\r' <|>if chars.clone().next().is_some() => {
|
||||||
|
t = 'e';
|
||||||
|
false
|
||||||
|
},
|
||||||
|
_ => true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Magic Completions
|
### Magic Completions
|
||||||
|
|
||||||
In addition to usual reference completion, rust-analyzer provides some ✨magic✨
|
In addition to usual reference completion, rust-analyzer provides some ✨magic✨
|
||||||
|
|
Loading…
Reference in a new issue