-
Notifications
You must be signed in to change notification settings - Fork 36
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
Do not implement Package trait automatically #10
Comments
One thing annoying in my opinion without default implementation is that users can only implement a trait on a type they own. So they could not use |
I did think it was an odd design, but we do need to cover the cases from std, and maybe some common crates. Could |
How to do that? |
In my mind, impl<P: Clone + Eq + Hash + Debug + Display, V: Version> Assignment<P, V> { But if there is a better way to make a "type alias" for traits that's a good idea. We could also just do the |
Yes, you are correct. I got |
This does bring up the related issue that impl<P: Package, V: Version + Hash> Solver<P, V> for BadSolver<P, V> {
fn list_available_versions(&mut self, package: &P) -> Result<Vec<V>, Box<dyn Error>> {
...
}
fn get_dependencies(
&mut self,
package: &P,
version: &V,
) -> Result<Option<Map<P, Range<V>>>, Box<dyn Error>> {
...
}
fn run(
&mut self,
package: P,
version: impl Into<V>
) -> Result<Map<P, V>, PubGrubError<P, V>> {
Ok(Map::new())
}
} I don't know why someone would, but our api lets them. Mabe |
interesting, I didn't think of that, do you mind if I split that comment into another issue? |
Yes, that exactly. |
I fail to see how that's better than the current solution. |
It's not implemented for every type automatically. It's like all fruits are oranges with the current solution. But not every fruit is an orange! |
I see the difference, but it's not necessarily better / solves any real problem is what I meant. |
@matthiasbeyer I understand this (https://stackoverflow.com/questions/26070559/is-there-any-way-to-create-a-type-alias-for-multiple-traits) to be a recommendation for the approach that this library with a blanket implementation. |
The discussion was quite interesting but it seems @matthiasbeyer that you are seeing this from the wrong perspective. We do not see |
I've just received this by email and thought I'd put it here to have more feedback. What do you think?
Implementing a trait for all other types that implement something is a
really bad design decision because it makes all types available to an
interface, but most types are not relevant for that interface.
That's especially bad in a case where the trait (here
Package
) hasfunctions associated with it. This is not the case here, as
Package
is a simple marker trait, so not too bad.
Still, making users of the library implement this is much better.
The text was updated successfully, but these errors were encountered: