Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_def/src/generics.rs')
| -rw-r--r-- | crates/hir_def/src/generics.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/hir_def/src/generics.rs b/crates/hir_def/src/generics.rs index 341d444d61..b5a11a1ba5 100644 --- a/crates/hir_def/src/generics.rs +++ b/crates/hir_def/src/generics.rs @@ -365,6 +365,13 @@ impl GenericParams { where_predicates.shrink_to_fit(); } + pub fn find_type_by_name(&self, name: &Name) -> Option<LocalTypeOrConstParamId> { + self.types + .iter() + .filter(|x| matches!(x.1, TypeOrConstParamData::TypeParamData(_))) + .find_map(|(id, p)| if p.name().as_ref() == Some(&name) { Some(id) } else { None }) + } + pub fn find_type_or_const_by_name(&self, name: &Name) -> Option<LocalTypeOrConstParamId> { self.types .iter() |