diff options
author | Aleksey Kladov <[email protected]> | 2019-11-26 12:27:33 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-26 12:36:25 +0000 |
commit | 45d05ed78384b28fbd341068f36912a2e0308292 (patch) | |
tree | 5b7f7abfc59e6e832be7fb0b22b3dcc704de946c /crates/ra_hir/src/code_model.rs | |
parent | 4c43631829d8bac8b7533c994d8cf1241a95ce70 (diff) |
id-ify impls_in_crate_query
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index bb1596bed..821f919d4 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -997,6 +997,15 @@ pub struct ImplBlock { | |||
997 | } | 997 | } |
998 | 998 | ||
999 | impl ImplBlock { | 999 | impl ImplBlock { |
1000 | pub fn all_in_crate(db: &impl HirDatabase, krate: Crate) -> Vec<ImplBlock> { | ||
1001 | let impls = db.impls_in_crate(krate.crate_id); | ||
1002 | impls.all_impls().map(Self::from).collect() | ||
1003 | } | ||
1004 | pub fn for_trait(db: &impl HirDatabase, krate: Crate, trait_: Trait) -> Vec<ImplBlock> { | ||
1005 | let impls = db.impls_in_crate(krate.crate_id); | ||
1006 | impls.lookup_impl_blocks_for_trait(trait_).map(Self::from).collect() | ||
1007 | } | ||
1008 | |||
1000 | pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> { | 1009 | pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> { |
1001 | db.impl_data(self.id).target_trait.clone() | 1010 | db.impl_data(self.id).target_trait.clone() |
1002 | } | 1011 | } |