aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/generics.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-02-20 21:36:54 +0000
committerFlorian Diebold <[email protected]>2019-02-20 21:48:55 +0000
commit72712b8a428e17d63c413522c770e8f1f0587455 (patch)
tree74455d20e5c1be76b1ecf43e9db448a0cae4bf95 /crates/ra_hir/src/generics.rs
parentc84561bb624280b84eb2fe6c6b2a6b9fe3f1dbf7 (diff)
Fix handling of generics in tuple variants and refactor a bit
Also make them display a tiny bit nicer. Fixes #860.
Diffstat (limited to 'crates/ra_hir/src/generics.rs')
-rw-r--r--crates/ra_hir/src/generics.rs13
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}