From 4fdeb54bb5c7ba0704839a65996766d223c51fc1 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 9 Feb 2019 01:57:08 +0100 Subject: Improve sorting delegate --- crates/ra_assists/src/lib.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'crates/ra_assists') diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index ce5ee365e..7928b4983 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs @@ -65,13 +65,11 @@ where Assist::Unresolved(..) => unreachable!(), }) .collect::>(); - a.sort_by(|a, b| match a { - // Some(y) < Some(x) < None for y < x - (_, AssistAction { target: Some(a), .. }) => match b { - (_, AssistAction { target: Some(b), .. }) => a.len().cmp(&b.len()), - _ => Ordering::Less, - }, - _ => Ordering::Greater, + a.sort_by(|a, b| match (a.1.target, b.1.target) { + (Some(a), Some(b)) => a.len().cmp(&b.len()), + (Some(_), None) => Ordering::Less, + (None, Some(_)) => Ordering::Greater, + (None, None) => Ordering::Equal, }); a }) -- cgit v1.2.3