Skip to content
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

Make DistroVersion more static #240

Closed
mikrostew opened this issue Jan 15, 2019 · 1 comment · Fixed by #505
Closed

Make DistroVersion more static #240

mikrostew opened this issue Jan 15, 2019 · 1 comment · Fixed by #505

Comments

@mikrostew
Copy link
Contributor

One issue that came out of #234 is that it should be possible to make DistroVersion more static (instead of a dynamic Enum), and verify the code correctness using the type system. This may be possible using some combination of Traits and associated types, but it was non-obvious how exactly to do that without blocking the PR for some time.

@charlespierce
Copy link
Contributor

I thought about this a little after seeing Dave's comment about associated types, and the only thing that immediately came to me would be inverting the control flow a little. Currently we are set up to do Inventory::fetch(tool), passing the tool that we want to fetch into a single inventory method.

If we instead made Tool into a Trait, with an associated Distro type (which itself has an associated Version type), then we could have Tool::fetch(collection), where we pass the Inventory Collection into the tool to do the fetching. We could use the associated Distro type to ensure that we are passing a Collection of the correct kind in, and getting the correct type out.

I haven't worked through all the intricacies of that approach though, perhaps I'll take a quick stab at it once #234 is merged to see if it's feasible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants