Add a short-circuiting case

This commit is contained in:
Cameron Steffen 2021-05-17 15:40:34 -05:00
parent 24743b3968
commit 0ebd5018bf

View File

@ -1572,8 +1572,10 @@ where
Hash: Fn(&T) -> u64,
Eq: Fn(&T, &T) -> bool,
{
if exprs.len() == 2 && eq(&exprs[0], &exprs[1]) {
return vec![(&exprs[0], &exprs[1])];
match exprs {
[a, b] if eq(a, b) => return vec![(a, b)],
_ if exprs.len() <= 2 => return vec![],
_ => {},
}
let mut match_expr_list: Vec<(&T, &T)> = Vec::new();