Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/ds/vector3.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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<H: Hasher>(&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,
Expand Down
Loading