From a4c6e8c4e22ddea9668eb3380603ad53d8ce6a5e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 5 Feb 2020 10:50:07 +0100 Subject: Refactor if-let -> match assist to use ast::make --- crates/ra_syntax/src/ast/expr_extensions.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'crates/ra_syntax/src/ast/expr_extensions.rs') 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::{ SyntaxToken, T, }; +impl ast::Expr { + pub fn is_block_like(&self) -> bool { + match self { + ast::Expr::IfExpr(_) + | ast::Expr::LoopExpr(_) + | ast::Expr::ForExpr(_) + | ast::Expr::WhileExpr(_) + | ast::Expr::BlockExpr(_) + | ast::Expr::MatchExpr(_) + | ast::Expr::TryBlockExpr(_) => true, + _ => false, + } + } +} + #[derive(Debug, Clone, PartialEq, Eq)] pub enum ElseBranch { Block(ast::BlockExpr), -- cgit v1.2.3