mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Handle not let if expressions in replace_if_let_with_match
This commit is contained in:
parent
20be999304
commit
8967856d78
2 changed files with 83 additions and 24 deletions
|
@ -430,6 +430,19 @@ pub fn match_arm(pats: impl IntoIterator<Item = ast::Pat>, expr: ast::Expr) -> a
|
|||
}
|
||||
}
|
||||
|
||||
pub fn match_arm_with_guard(
|
||||
pats: impl IntoIterator<Item = ast::Pat>,
|
||||
guard: ast::Expr,
|
||||
expr: ast::Expr,
|
||||
) -> ast::MatchArm {
|
||||
let pats_str = pats.into_iter().join(" | ");
|
||||
return from_text(&format!("{} if {} => {}", pats_str, guard, expr));
|
||||
|
||||
fn from_text(text: &str) -> ast::MatchArm {
|
||||
ast_from_text(&format!("fn f() {{ match () {{{}}} }}", text))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn match_arm_list(arms: impl IntoIterator<Item = ast::MatchArm>) -> ast::MatchArmList {
|
||||
let arms_str = arms
|
||||
.into_iter()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue