Skip to content

Commit 0ebd501

Browse files
committed
Add a short-circuiting case
1 parent 24743b3 commit 0ebd501

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clippy_utils/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,10 @@ where
15721572
Hash: Fn(&T) -> u64,
15731573
Eq: Fn(&T, &T) -> bool,
15741574
{
1575-
if exprs.len() == 2 && eq(&exprs[0], &exprs[1]) {
1576-
return vec![(&exprs[0], &exprs[1])];
1575+
match exprs {
1576+
[a, b] if eq(a, b) => return vec![(a, b)],
1577+
_ if exprs.len() <= 2 => return vec![],
1578+
_ => {},
15771579
}
15781580

15791581
let mut match_expr_list: Vec<(&T, &T)> = Vec::new();

0 commit comments

Comments
 (0)