Skip to content

Commit b227f23

Browse files
committed
use if let
1 parent 3c6d2f4 commit b227f23

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
@@ -383,15 +383,14 @@ fn take_pat(from: &mut Pat) -> Pat {
383383
/// in `tail_or` if there are any and return if there were.
384384
fn extend_with_tail_or(target: &mut Pat, tail_or: ThinVec<Box<Pat>>) -> bool {
385385
fn extend(target: &mut Pat, mut tail_or: ThinVec<Box<Pat>>) {
386-
match &mut target.kind {
387-
// On an existing or-pattern in the target, append to it.
388-
Or(ps) => ps.append(&mut tail_or),
389-
// Otherwise convert the target to an or-pattern.
390-
_ => {
391-
let mut init_or = thin_vec![Box::new(take_pat(target))];
392-
init_or.append(&mut tail_or);
393-
target.kind = Or(init_or);
394-
},
386+
// On an existing or-pattern in the target, append to it,
387+
// otherwise convert the target to an or-pattern.
388+
if let Or(ps) = &mut target.kind {
389+
ps.append(&mut tail_or);
390+
} else {
391+
let mut init_or = thin_vec![Box::new(take_pat(target))];
392+
init_or.append(&mut tail_or);
393+
target.kind = Or(init_or);
395394
}
396395
}
397396

0 commit comments

Comments
 (0)