use num::*; use std::ops::*; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct Euclidian where T: Integer, { pub x: T, pub y: T, pub z: T, } impl Add for Euclidian { fn add(self, rhs: Self) -> Self::Output { Euclidian { x: self.x + rhs.x, y: self.y + rhs.y, z: self.z + rhs.z, } } type Output = Euclidian; } impl AddAssign for Euclidian { fn add_assign(&mut self, rhs: Self) { self.x += rhs.x; self.y += rhs.y; self.z += rhs.z; } } impl Sub for Euclidian { fn sub(self, rhs: Self) -> Self::Output { Euclidian { x: self.x - rhs.x, y: self.y - rhs.y, z: self.z - rhs.z, } } type Output = Euclidian; } impl SubAssign for Euclidian { fn sub_assign(&mut self, rhs: Self) { self.x -= rhs.x; self.y -= rhs.y; self.z -= rhs.z; } } impl Euclidian { pub const fn new(x: T, y: T, z: T) -> Self { Self { x: x, y: y, z: z } } } #[cfg(test)] mod test { use super::*; }