How can I implement `From` trait for a generic type with two different params?

I want to make the following example compile, but it returns an error: "error[E0119]: conflicting implementations of trait From<A<_>> for type A<_>"

I know that "auto trait" combined "negative impl" may have worked before, however, it fails due to the forbid conditional issue in the recent night version.

Is there any way I can let it pass?

Without specialization being stabilized (which won't happen any time soon), I don't think there's a way to write your generic trait implementation like that.

2 Likes

Bad news but I believe it is true, I think I should try some workarounds to solve my problem. Thank you @jofas

1 Like

No such thing like where T != U.

If you got some workarounds please let me know.

It's not the same because it isn't using the From trait but something like this playground might help if you don't need the From trait

Thanks for your reply but I need to implement some auto-conversion, so your solution may not suit me.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.