Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/generics.rs')
-rw-r--r--crates/hir-ty/src/generics.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/hir-ty/src/generics.rs b/crates/hir-ty/src/generics.rs
index 7f8dd920e6..2685dc0ef8 100644
--- a/crates/hir-ty/src/generics.rs
+++ b/crates/hir-ty/src/generics.rs
@@ -20,6 +20,7 @@ use hir_def::{
LocalLifetimeParamId, LocalTypeOrConstParamId, Lookup, TypeOrConstParamId, TypeParamId,
};
use intern::Interned;
+use stdx::TupleExt;
use crate::{db::HirDatabase, lt_to_placeholder_idx, to_placeholder_idx, Interner, Substitution};
@@ -57,7 +58,7 @@ impl Generics {
self.iter_self().map(|(id, _)| id)
}
- fn iter_parent_id(&self) -> impl Iterator<Item = GenericParamId> + '_ {
+ pub(crate) fn iter_parent_id(&self) -> impl Iterator<Item = GenericParamId> + '_ {
self.iter_parent().map(|(id, _)| id)
}
@@ -67,6 +68,16 @@ impl Generics {
self.params.iter_type_or_consts()
}
+ pub(crate) fn iter_self_type_or_consts_id(
+ &self,
+ ) -> impl DoubleEndedIterator<Item = GenericParamId> + '_ {
+ self.params.iter_type_or_consts().map(from_toc_id(self)).map(TupleExt::head)
+ }
+
+ pub(crate) fn iter_self_lt_id(&self) -> impl DoubleEndedIterator<Item = GenericParamId> + '_ {
+ self.params.iter_lt().map(from_lt_id(self)).map(TupleExt::head)
+ }
+
/// Iterate over the params followed by the parent params.
pub(crate) fn iter(
&self,