-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dedup dependencies #293
dedup dependencies #293
Conversation
Nice! Pretty much the same as #292, but I think I like this one more. |
4f83cfe
to
41c66e4
Compare
I explored if generating a custom It's definetely possible, but I think it'd require a breaking change to be nice. What I had in mind was fn dependency_types() -> impl TypeList {
#[derive(Copy, Clone)]
struct Deps;
impl TypeList for Deps {
fn for_each(self, v: &mut impl TypeVisitor) {
v.visit::<TypeOfField1>();
v.visit::<TypeOfField2>();
Something::dependency_types().for_each(v);
SomethingElse::generics().for_each(v);
}
}
Deps
} This breaks with generic parameters though. The naive If we changed So tl;dr: I think we should go ahead with this, and keep this change in mind if someone still runs into the issue or for a breaking 9.0 release some time in the future. |
Note to myself: Add two tests from other branch. |
So, I've added some reference counting (probably doesn't have a big performance impact, but it felt like the right thing to do), added the test from the other branch and used a From my side, this is ready to merge. |
Thanks @kamadorueda for getting this of the ground! |
Goal
Generate TypeLists containing less duplicates.
Mentions #291 #289
Changes
This is an Internal API change, use a HashSet instead of a Vec, and delay formatting until just when it's needed.
Checklist