ToString is automatically implemented for types implementing Display
thus in my implementation of impl<T:ToString> From<T> for Dummy T also matches Dummy
but there is also impl<T> From<T> for T in std, which also matches Dummy
and thus the conflict.
I guess in future specialization can resolve it. In the meanwhile is there any way how to implement these traits for Dummy - e.g. it can be both From<ToString> and Display ?
How about impl<T: ToString + !fmt::Display>, does that work?
I guess, you don't want to rule out types that implement Display. In that case create DummyTrait that is only implemented for Dummy and then do impl<T: ToString + !DummyTrait>.
Also I quickly tried nightly with #![feature(specialization)], but it also does not work. So I'd also be interesting why specialization is not working in this case - impl<T:ToString> From<T> for Dummy should be more special that impl<T> From<T> for T?
Thanks, understood, it's how std traits are set up.
But still wonder why specialization does not work? I thought that impl<T:ToString> From<T> for Dummy should be more 'special' sot it should fix the conflict?
To use specialization you have to mark one of them default, but since the one in std is the more general one, that is the one that needs the default marker, so you can't add it.
Oh, I see, but why I can have default for more specific type (implementing for my local type Dummy), if this type is local to crate it cannot do any harm elsewhere, or could it?
Since the one in the standard library is not marked default, other crates would be able to assume that, even in generic code, that if they call this implementation, they get the one in the standard library. If you could override it, that crate would not be able to assume this.