Skip to content

Commit 4fdeb54

Browse files
committed
Improve sorting delegate
1 parent a705897 commit 4fdeb54

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

crates/ra_assists/src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,11 @@ where
6565
Assist::Unresolved(..) => unreachable!(),
6666
})
6767
.collect::<Vec<(AssistLabel, AssistAction)>>();
68-
a.sort_by(|a, b| match a {
69-
// Some(y) < Some(x) < None for y < x
70-
(_, AssistAction { target: Some(a), .. }) => match b {
71-
(_, AssistAction { target: Some(b), .. }) => a.len().cmp(&b.len()),
72-
_ => Ordering::Less,
73-
},
74-
_ => Ordering::Greater,
68+
a.sort_by(|a, b| match (a.1.target, b.1.target) {
69+
(Some(a), Some(b)) => a.len().cmp(&b.len()),
70+
(Some(_), None) => Ordering::Less,
71+
(None, Some(_)) => Ordering::Greater,
72+
(None, None) => Ordering::Equal,
7573
});
7674
a
7775
})

0 commit comments

Comments
 (0)