From 079ed6011a1febafef4bcb209c7433a415642d19 Mon Sep 17 00:00:00 2001 From: Unreal Hoang Date: Thu, 16 May 2019 12:56:54 +0900 Subject: add feature doc --- docs/user/features.md | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/user/features.md b/docs/user/features.md index a714574fb..22470bc56 100644 --- a/docs/user/features.md +++ b/docs/user/features.md @@ -390,14 +390,14 @@ fn foo() { - Move guard expression to match arm body ```rust -//before: +// before: fn f() { match x { <|>y @ 4 | y @ 5 if y > 5 => true, _ => false } } -//after: +// after: fn f() { match x { 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 In addition to usual reference completion, rust-analyzer provides some ✨magic✨ -- cgit v1.2.3