use if let
This commit is contained in:
parent
adf38c0b62
commit
31b7ddc939
1 changed files with 8 additions and 9 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue