mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
expose hir::Type::type_paramters
Used to get E parameter from `Result<T, E>`
This commit is contained in:
parent
4be260d693
commit
37a8cec638
2 changed files with 17 additions and 24 deletions
|
@ -1802,6 +1802,18 @@ impl Type {
|
|||
None
|
||||
}
|
||||
|
||||
pub fn type_parameters(&self) -> impl Iterator<Item = Type> + '_ {
|
||||
let ty = self.ty.value.strip_references();
|
||||
let substs = match ty {
|
||||
Ty::Apply(apply_ty) => &apply_ty.parameters,
|
||||
Ty::Opaque(opaque_ty) => &opaque_ty.parameters,
|
||||
_ => return Either::Left(iter::empty()),
|
||||
};
|
||||
|
||||
let iter = substs.iter().map(move |ty| self.derived(ty.clone()));
|
||||
Either::Right(iter)
|
||||
}
|
||||
|
||||
pub fn iterate_method_candidates<T>(
|
||||
&self,
|
||||
db: &dyn HirDatabase,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue