I'm really looking forward to this feature, but sadly its progressing very slowly, I was trying to figure out the reasons for it but most of it was going over my head as I think I don't understand how things work under the hood enough.
What I was expecting would be something like this, when you specify a concrete type, it would take prority over a generic one, the closer match for the concrete type would be chosen:
trait Foo;
// Highest priority to lowest
impl Foo for Option<String> {}
impl<T> Foo for Opotion<T> {}
impl<T> Foo for &T {}
impl<T> Foo for T {}
I also couldn't really understand the role lifetimes play in all this, and why its such a big issue, from the way I imagined it would go, if you implement the same trait for a &T and the same trait for &'a T, they would still count as &T and cause a conflict, but are they technically entirely different types ? Because I think having specialization over lifetimes would be overkill.
This should be possible with min_specialization. However generally people look forward to specialization on whether a trait is implemented or not (i.e. a impl <T: Bar> Foo for T or something like that), and this ends up with all the lifetimes problems.
Lifetime specialization is a problem because when the compiler actually generates code it no longer knows about lifetimes, thus if the specialized implementation requires some specific lifetimes (e.g. a lifetime to be 'static, or two lifetimes 'a and 'b to be somehow related) then it no longer knows which implementation to use (is it the specialized one or the normal one?)
Lifetime specialization is not something you would want to write yourself, but unfortunately it comes up implicitly all the time. Do you want to write a specialized implementation for (T, T) for some generic type T? Unfortunately if T contains a lifetime you just forced two lifetimes to be equal, which is lifetime specialization! Do you want to specialize on whether T implements a trait Foo? Unfortunately any user can write a impl Foo for &'static Bar or impl<T> Foo for (T, T), and now your specialization depends on lifetimes again.