I have about 12 types representing time and I want to be able to convert between any of them. To avoid the n-squared problem I will be going through an interim type designed to avoid loss of precision.
I can define From back and forth to the interim types.
But I can't seem to generically define how to go from any of them to any other using that pathway. This doesn't work:
impl<T1: Time, T2: Time> From<T1> for T2 {
fn from(t1: T1) -> T2 {
let x: Interim = t1.into();
From::from(x)
}
}
Because T1 could equal T2 and that collides with
impl<T> std::convert::From<T> for T
in the standard library. And I dont know how to write "T1 != T2" in the where clause.
Also, 'error[E0210]: type parameter T2
must be used as the type parameter for some local type (e.g., MyStruct<T2>
)'