I want to implement the trait TryFrom in a case like this:
struct T1;
struct T2(T1);
impl<U> TryFrom<U> for T2 where U: Into<T1> {
type Error = ();
fn try_from(val:U) -> Result<T2, Self::Error> {
unimplemented!();
}
}
which gives me this error:
error[E0119]: conflicting implementations of trait `std::convert::TryFrom<_>` for type `T2`
--> src/lib.rs:4:1
|
4 | impl<U> TryFrom<U> for T2 where U: Into<T1> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<T, U> TryFrom<U> for T
where U: Into<T>;
Here U implement Into<T1> not Into<T2> thus I don't really understand the error. I tried to confirm there is no blanket implementation by implementing this and it compiles without conflict:
struct T1;
struct T2(T1);
impl Into<T2> for T1 {
fn into(self) -> T2 {
unimplemented!();
}
}
Is there any way around it? I don't want a default implementation here.