Skip to content

Commit 31b7ddc

Browse files
committed
use if let
1 parent adf38c0 commit 31b7ddc

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

clippy_lints/src/unnested_or_patterns.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -385,15 +385,14 @@ fn take_pat(from: &mut Pat) -> Pat {
385385
/// in `tail_or` if there are any and return if there were.
386386
fn extend_with_tail_or(target: &mut Pat, tail_or: ThinVec<Pat>) -> bool {
387387
fn extend(target: &mut Pat, mut tail_or: ThinVec<Pat>) {
388-
match &mut target.kind {
389-
// On an existing or-pattern in the target, append to it.
390-
Or(ps) => ps.append(&mut tail_or),
391-
// Otherwise convert the target to an or-pattern.
392-
_ => {
393-
let mut init_or = thin_vec![take_pat(target)];
394-
init_or.append(&mut tail_or);
395-
target.kind = Or(init_or);
396-
},
388+
// On an existing or-pattern in the target, append to it,
389+
// otherwise convert the target to an or-pattern.
390+
if let Or(ps) = &mut target.kind {
391+
ps.append(&mut tail_or);
392+
} else {
393+
let mut init_or = thin_vec![take_pat(target)];
394+
init_or.append(&mut tail_or);
395+
target.kind = Or(init_or);
397396
}
398397
}
399398

0 commit comments

Comments
 (0)