diff --git a/src/ds/vector3.rs b/src/ds/vector3.rs index 9295895..27a7e82 100644 --- a/src/ds/vector3.rs +++ b/src/ds/vector3.rs @@ -1,8 +1,9 @@ use auto_ops::*; use rand; use rand::RngExt; +use std::hash::{Hash, Hasher}; -#[derive(PartialEq, Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug)] pub struct Vector3 { pub x: f64, pub y: f64, @@ -91,6 +92,24 @@ impl Vector3 { } } +impl PartialEq for Vector3 { + fn eq(&self, other: &Self) -> bool { + self.x.to_bits() == other.x.to_bits() && + self.y.to_bits() == other.y.to_bits() && + self.z.to_bits() == other.z.to_bits() + } +} + +impl Eq for Vector3 {} + +impl Hash for Vector3 { + fn hash(&self, state: &mut H) { + self.x.to_bits().hash(state); + self.y.to_bits().hash(state); + self.z.to_bits().hash(state); + } +} + impl_op_ex!(+ |a: &Vector3, b: &Vector3| -> Vector3{ Vector3{ x: a.x + b.x,