← Back to context

Comment by dwattttt

10 days ago

They didn't special case this (in this way at least). You only need to specify the bounds relevant to this impl at this point.

It doesn't even have to be less constrained than the containing types definition. You can provide an impl with more constraints; for example, a type Q<T: Read + Write>, but impl Seek for Q<T: Read + Seek>

I thought only as constrained and more constrained is allowed, and less constrained is always an error. At least that's been my experience - if `Q<T: A>`, then I could never get `impl<T> Q<T>` working in any conditions until I added `where T: A`.

Do you happen to know the specific rules of when it's an error and when it's not?

  • It looks like you're right, my memory is wrong re. trait bounds. My guess then is that it only works for lifetimes because they involve subtyping, and impl Drop for all T means that it's valid for more constrained lifetimes.

    That said I was wrong earlier.