#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct Vec2 { pub x: T, pub y: T, } impl Vec2 { pub const ZERO: Vec2 = Vec2 { x: 0, y: 0 }; pub const UP: Vec2 = Vec2 { x: 0, y: -1 }; pub const LEFT: Vec2 = Vec2 { x: -1, y: 0 }; } impl Vec2 { pub const ZERO: Vec2 = Vec2 { x: 0.0, y: 0.0 }; pub const UP: Vec2 = Vec2 { x: 0.0, y: -1.0 }; pub const LEFT: Vec2 = Vec2 { x: -1.0, y: 0.0 }; } impl + Copy> Vec2 { pub fn downscale(&self, f: T) -> Self { Self { x: self.x / f, y: self.y / f, } } } impl std::ops::Add for Vec2 { type Output = Vec2; #[inline] fn add(self, rhs: Self) -> Self::Output { Vec2 { x: self.x + rhs.x, y: self.y + rhs.y, } } } impl std::ops::Sub for Vec2 { type Output = Vec2; #[inline] fn sub(self, rhs: Self) -> Self::Output { Vec2 { x: self.x - rhs.x, y: self.y - rhs.y, } } } impl std::ops::Mul for Vec2 { type Output = Vec2; #[inline] fn mul(self, rhs: Self) -> Self::Output { Vec2 { x: self.x * rhs.x, y: self.y * rhs.y, } } } impl From<(T, T)> for Vec2 { #[inline] fn from((x, y): (T, T)) -> Self { Vec2 { x, y } } }