brief code as below:
use std::ops::Add;
struct A{
val: String
}
type
impl From<i64> for A {
fn from(c: i64) -> Self {
A{
val: c.to_string()
}
}
}
//it warns: Type parameter `T` must be covered by another type when it appears before the first local
impl<T: Into<A>> Add<A> for T {
type Output = A;
fn add(self, rhs: A) -> Self::Output {
if let A { val:x } = rhs{
A { val: self.to_string + x }
}
}
}
fn main(){
}
I have many kinds of objects to be Add to struct A, for those objects I impl the From to A for them.
I didn't want to write Add for each type of those objects, I wanna generics to deal with it.
how to avoid this error,? thanks advanced.