pub struct Foo<T>(pub T);
impl<T> Into<T> for Foo<T> {
fn into(self) -> T {
self.0
}
}
gives the confilcting implementations error as Into<T> for T is implemented by default, so Into<Foo> for Foo has multiple confilcting implementations. I think?
So is there a way of doing this, perhaps a way of saying "where T is not Foo"?
edit: it is the impl Into<U> for T where U: From<T> which conflicts
No, the problem is that this implementation of Into<U> for T where U: From<T> exist. It's not clear to the compiler if it should use your Into<T> implementation for Foo or the generic one from the standard library, which is implemented on Foo as well. This problem is supposed to be solved with specialization, but that won't be stabilized anytime soon (there are still open soundness holes last time I checked).
I tried this in playground when writing a reply and it became immediately obvious why topic starter did not: you cannot write impl<T> From<Foo<T>> for T due to orphan rules. I really should have spotted this without trying code in playground…
Negative reasoning for coherence is only used for local traits/types, as otherwise adding an implementation to your own type could be a breaking change to downstream. So the where clause doesn't really matter in that case.
I don't have time to dig them up right now, but I know there have been other conversations about it with regards to From/Into/TryFrom/TryInto on this forum and elsewhere before (because they are so blanket-implementation encumbered).