Cannot apply unary operator to `Num`

Hi i want implement the simple Neg trait for a custom type like:

impl<T: Num + Copy> Neg for V3<T> {
    type Output = Self;
    fn neg(self) -> Self {
        let a = self[0];
        let b = self[1];
        let c = self[2];
        V3::new([-a, -b, -c])
    }
}

But i got the unary operator Error, with Floats works fine

   |
90 |         V3::new([-a, -b, -c])
   |                  ^^ cannot apply unary operator `-`

I don't know how to solve it

The Num trait doesn't include Neg, because that would exclude unsigned integers. You could require T: Signed, or directly T: Neg<Output = T>.

1 Like

oh yeah i forget the Signed !!! thank for your time!!!
Regards