Hello,
when I have a struct like this:
struct Foo<T> where T: Add<T,T> + Sub<T,T> {bar: T}
It's obvious that for all trait implementations this template constraint will still be true.
So why not remove this constraint from the traits, that is, replace:
impl<T> Add<T, T> for Foo<T> where T: Add<T,T> + Sub<T,T> {
fn add(self, rhs: T) -> T {
self.bar + rhs
}}
by
impl<T> Add<T, T> for Foo<T> {
fn add(self, rhs: T) -> T {
self.bar + rhs
}
}
Currently, if I do so, I get the following errors:
error: the trait
core::ops::Add<T, T>
is not implemented for the typeT
error: the traitcore::ops::Sub<T, T>
is not implemented for the typeT
It's not so bad in this minimal example, but it becomes really painful when there is more constraints on 'T' and Foo implements more traits. Especially as we have to copy-paste all constraints even those not used in this specific trait.