diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-05 13:20:32 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-05 13:20:32 +0000 |
commit | 8d0f7da2f5f2ae1dc5711005f08fde0007da165b (patch) | |
tree | 24f302e769cd8d2e27b6ab7a39b2df1376b65660 /crates/ra_syntax/src/ast/expr_extensions.rs | |
parent | 83dc22e1fb4ff4897d911c18884259823edb68ba (diff) | |
parent | a4c6e8c4e22ddea9668eb3380603ad53d8ce6a5e (diff) |
Merge #3018
3018: Refactor if-let -> match assist to use ast::make r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast/expr_extensions.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/expr_extensions.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index 539759450..2e50a095c 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs | |||
@@ -7,6 +7,21 @@ use crate::{ | |||
7 | SyntaxToken, T, | 7 | SyntaxToken, T, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | impl ast::Expr { | ||
11 | pub fn is_block_like(&self) -> bool { | ||
12 | match self { | ||
13 | ast::Expr::IfExpr(_) | ||
14 | | ast::Expr::LoopExpr(_) | ||
15 | | ast::Expr::ForExpr(_) | ||
16 | | ast::Expr::WhileExpr(_) | ||
17 | | ast::Expr::BlockExpr(_) | ||
18 | | ast::Expr::MatchExpr(_) | ||
19 | | ast::Expr::TryBlockExpr(_) => true, | ||
20 | _ => false, | ||
21 | } | ||
22 | } | ||
23 | } | ||
24 | |||
10 | #[derive(Debug, Clone, PartialEq, Eq)] | 25 | #[derive(Debug, Clone, PartialEq, Eq)] |
11 | pub enum ElseBranch { | 26 | pub enum ElseBranch { |
12 | Block(ast::BlockExpr), | 27 | Block(ast::BlockExpr), |