mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Add method to get generic parameters in a type
This commit is contained in:
parent
0df70d37fc
commit
32955c30cd
2 changed files with 76 additions and 1 deletions
|
@ -3599,6 +3599,14 @@ impl Type {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns unique `GenericParam`s contained in this type.
|
||||
pub fn generic_params(&self, db: &dyn HirDatabase) -> FxHashSet<GenericParam> {
|
||||
hir_ty::collect_placeholders(&self.ty, db)
|
||||
.into_iter()
|
||||
.map(|id| TypeOrConstParam { id }.split(db).either_into())
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue