gfxmath_vec2/impls/neg/neg.rs
1use core::ops::Neg;
2use crate::Vec2;
3
4/// Scalar multiplication with vector
5///
6/// ```
7/// use gfxmath_vec2::Vec2;
8///
9/// let a = Vec2::<f32>::new(2.0, 6.0);
10///
11/// let res = -a;
12///
13/// assert_eq!(-2.0, res.x);
14/// assert_eq!(-6.0, res.y);
15/// ```
16#[opimps::impl_uni_ops(Neg)]
17#[inline]
18fn neg<T>(self: Vec2<T>) -> Vec2<T> where T: Neg<Output = T> + Copy {
19 Vec2 { x: -self.x, y: -self.y }
20}