/// A 2D vector. #[derive(Debug, Clone, Copy, PartialEq)] pub struct Vector { pub x: T, pub y: T, } impl Vector { /// Creates a new [`Vector`] with the given components. /// /// [`Vector`]: struct.Vector.html pub fn new(x: T, y: T) -> Self { Self { x, y } } } impl std::ops::Add for Vector where T: std::ops::Add, { type Output = Self; fn add(self, b: Self) -> Self { Self::new(self.x + b.x, self.y + b.y) } }