aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs20
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}