How to overload an operator for a common right operand?

I have a generic type Vec2<T>for which I would like to perform the following operation:

Vec2<T> = T * Vec2<T>

I tried this:

impl<T: Copy + Mul<Output = T>> Mul<Vec2<T>> for T {
    type Output = Vec2<T>;

    fn mul(self, rhs: Vec2<T>) -> Vec2<T> {
        Vec2 {
            x: self * rhs.x,
            y: self * rhs.y,
        }
    }
}

But I get this error:

a type parameter Tshould be used as a type parameter for some local type (for example, MyStruct<T>); only traits defined in the current box can be implemented for a type parameter

What is the standard way to overload an operator with your own type as the right operand?

[EDIT]

The answer seems to be that you cannot do this at this time. In "duplicates" there are answers to related questions. I am waiting for an update in this language so that this question can be reopened and a real answer can be given.

+6

All Articles