that already implemented inside std::convert as generic:
// From (and thus Into) is reflexive
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> From<T> for T {
fn from(t: T) -> T { t }
}
you don't have to declare, it works out of the box:
use std::convert::From;
trait Trait {
type A;
}
struct Type<T: Trait>(pub T::A);
impl Trait for i32 {
type A = i32;
}
fn main() {
let x = Type::<i32>(0);
let y = Type::from(x);
}
Thank you for your swift reply. I still do not quite understand how this particular instance of From can apply here. While I understand the reflexive implementation from T to T I fail to see how it can apply to convert T::A to Type<T>.