Refactor if-let -> match assist to use ast::make

This commit is contained in:
Aleksey Kladov 2020-02-05 10:50:07 +01:00
parent 83dc22e1fb
commit a4c6e8c4e2
4 changed files with 55 additions and 32 deletions

View file

@ -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),