Fix handling of generics in tuple variants and refactor a bit

Also make them display a tiny bit nicer.

Fixes #860.
This commit is contained in:
Florian Diebold 2019-02-20 22:36:54 +01:00
parent c84561bb62
commit 72712b8a42
6 changed files with 122 additions and 41 deletions

View file

@ -87,4 +87,17 @@ impl GenericParams {
let parent_count = self.count_parent_params();
parent_count + self.params.len()
}
fn for_each_param<'a>(&'a self, f: &mut impl FnMut(&'a GenericParam)) {
if let Some(parent) = &self.parent_params {
parent.for_each_param(f);
}
self.params.iter().for_each(f);
}
pub fn params_including_parent(&self) -> Vec<&GenericParam> {
let mut vec = Vec::with_capacity(self.count_params_including_parent());
self.for_each_param(&mut |p| vec.push(p));
vec
}
}