diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-12 11:07:21 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-12 11:07:21 +0000 |
commit | 19718ea109eae2f933ce3464c73879c09f9bdbe2 (patch) | |
tree | e7bddef556f430d31903a54fced0df760673a0e8 /crates/ra_hir/src | |
parent | 37148000dcd43e5ccba4737a3e379f1ae6861893 (diff) | |
parent | 7e8527f74831b37c5757ea6b25e40bcbb61bb6d4 (diff) |
Merge #801
801: Implement completion for associated items r=matklad a=lnicola
Fixes #747.
r? @matklad
Co-authored-by: Laurențiu Nicola <[email protected]>
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index b8e911b88..e81bd3e06 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -174,4 +174,24 @@ impl Ty { | |||
174 | } | 174 | } |
175 | None | 175 | None |
176 | } | 176 | } |
177 | |||
178 | // This would be nicer if it just returned an iterator, but that runs into | ||
179 | // lifetime problems, because we need to borrow temp `CrateImplBlocks`. | ||
180 | pub fn iterate_impl_items<T>( | ||
181 | self, | ||
182 | db: &impl HirDatabase, | ||
183 | mut callback: impl FnMut(ImplItem) -> Option<T>, | ||
184 | ) -> Option<T> { | ||
185 | let krate = def_crate(db, &self)?; | ||
186 | let impls = db.impls_in_crate(krate); | ||
187 | |||
188 | for (_, impl_block) in impls.lookup_impl_blocks(db, &self) { | ||
189 | for item in impl_block.items() { | ||
190 | if let Some(result) = callback(*item) { | ||
191 | return Some(result); | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | None | ||
196 | } | ||
177 | } | 197 | } |