use if let

This commit is contained in:
Ada Alakbarova 2025-07-25 18:25:04 +02:00
parent adf38c0b62
commit 31b7ddc939
No known key found for this signature in database

View file

@ -385,15 +385,14 @@ fn take_pat(from: &mut Pat) -> Pat {
/// in `tail_or` if there are any and return if there were.
fn extend_with_tail_or(target: &mut Pat, tail_or: ThinVec<Pat>) -> bool {
fn extend(target: &mut Pat, mut tail_or: ThinVec<Pat>) {
match &mut target.kind {
// On an existing or-pattern in the target, append to it.
Or(ps) => ps.append(&mut tail_or),
// Otherwise convert the target to an or-pattern.
_ => {
let mut init_or = thin_vec![take_pat(target)];
init_or.append(&mut tail_or);
target.kind = Or(init_or);
},
// On an existing or-pattern in the target, append to it,
// otherwise convert the target to an or-pattern.
if let Or(ps) = &mut target.kind {
ps.append(&mut tail_or);
} else {
let mut init_or = thin_vec![take_pat(target)];
init_or.append(&mut tail_or);
target.kind = Or(init_or);
}
}