diff options
Diffstat (limited to 'crates/ra_assists')
-rw-r--r-- | crates/ra_assists/src/lib.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index fcdfe6c14..b71df7e5d 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs | |||
@@ -11,6 +11,8 @@ mod marks; | |||
11 | mod doc_tests; | 11 | mod doc_tests; |
12 | pub mod ast_transform; | 12 | pub mod ast_transform; |
13 | 13 | ||
14 | use std::cmp::Ordering; | ||
15 | |||
14 | use either::Either; | 16 | use either::Either; |
15 | use ra_db::FileRange; | 17 | use ra_db::FileRange; |
16 | use ra_ide_db::RootDatabase; | 18 | use ra_ide_db::RootDatabase; |
@@ -85,13 +87,12 @@ pub fn resolved_assists(db: &RootDatabase, range: FileRange) -> Vec<ResolvedAssi | |||
85 | Assist::Resolved { assist } => assist, | 87 | Assist::Resolved { assist } => assist, |
86 | Assist::Unresolved { .. } => unreachable!(), | 88 | Assist::Unresolved { .. } => unreachable!(), |
87 | }) | 89 | }) |
88 | .collect(); | 90 | .collect::<Vec<_>>(); |
89 | sort_assists(&mut a); | 91 | sort_assists(&mut a); |
90 | a | 92 | a |
91 | } | 93 | } |
92 | 94 | ||
93 | fn sort_assists(assists: &mut Vec<ResolvedAssist>) { | 95 | fn sort_assists(assists: &mut [ResolvedAssist]) { |
94 | use std::cmp::Ordering; | ||
95 | assists.sort_by(|a, b| match (a.get_first_action().target, b.get_first_action().target) { | 96 | assists.sort_by(|a, b| match (a.get_first_action().target, b.get_first_action().target) { |
96 | (Some(a), Some(b)) => a.len().cmp(&b.len()), | 97 | (Some(a), Some(b)) => a.len().cmp(&b.len()), |
97 | (Some(_), None) => Ordering::Less, | 98 | (Some(_), None) => Ordering::Less, |