diff options
Diffstat (limited to 'crates/ra_hir/src/generics.rs')
-rw-r--r-- | crates/ra_hir/src/generics.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs index fcc513353..c494beeb0 100644 --- a/crates/ra_hir/src/generics.rs +++ b/crates/ra_hir/src/generics.rs | |||
@@ -87,4 +87,17 @@ impl GenericParams { | |||
87 | let parent_count = self.count_parent_params(); | 87 | let parent_count = self.count_parent_params(); |
88 | parent_count + self.params.len() | 88 | parent_count + self.params.len() |
89 | } | 89 | } |
90 | |||
91 | fn for_each_param<'a>(&'a self, f: &mut impl FnMut(&'a GenericParam)) { | ||
92 | if let Some(parent) = &self.parent_params { | ||
93 | parent.for_each_param(f); | ||
94 | } | ||
95 | self.params.iter().for_each(f); | ||
96 | } | ||
97 | |||
98 | pub fn params_including_parent(&self) -> Vec<&GenericParam> { | ||
99 | let mut vec = Vec::with_capacity(self.count_params_including_parent()); | ||
100 | self.for_each_param(&mut |p| vec.push(p)); | ||
101 | vec | ||
102 | } | ||
90 | } | 103 | } |