Skip to content

Commit 9c74a5b

Browse files
committed
minor: reduce duplication
1 parent f04f8dd commit 9c74a5b

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

crates/ide_assists/src/handlers/replace_if_let_with_match.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,7 @@ pub(crate) fn replace_match_with_if_let(acc: &mut Assists, ctx: &AssistContext)
210210
ast::Expr::BlockExpr(block) => block,
211211
expr => make::block_expr(iter::empty(), Some(expr)),
212212
};
213-
let else_expr = match else_expr {
214-
ast::Expr::BlockExpr(block) if block.is_empty() => None,
215-
ast::Expr::TupleExpr(tuple) if tuple.fields().next().is_none() => None,
216-
expr => Some(expr),
217-
};
213+
let else_expr = if is_empty_expr(&else_expr) { None } else { Some(else_expr) };
218214
let if_let_expr = make::expr_if(
219215
condition,
220216
then_block,

0 commit comments

Comments
 (0)