From f7b3860bb6b4ab0b0af3d5416249bb29542d8a84 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Sat, 19 Feb 2022 11:23:51 +0100 Subject: [PATCH] Derive `Hash` for most math types In #214, I already declared that I did this, and closed #193 for good measure. Here I'm actually doing it. --- src/math/aabb.rs | 2 +- src/math/point.rs | 2 +- src/math/segment.rs | 2 +- src/math/triangle.rs | 2 +- src/math/vector.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/math/aabb.rs b/src/math/aabb.rs index db1ba105f..72d88d224 100644 --- a/src/math/aabb.rs +++ b/src/math/aabb.rs @@ -3,7 +3,7 @@ use parry3d_f64::bounding_volume::BoundingVolume as _; use super::{Point, Vector}; /// An axis-aligned bounding box (AABB) -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Ord, PartialOrd)] pub struct Aabb { /// The minimum coordinates of the AABB pub min: Point, diff --git a/src/math/point.rs b/src/math/point.rs index 1b0571241..bc11fb811 100644 --- a/src/math/point.rs +++ b/src/math/point.rs @@ -12,7 +12,7 @@ use super::{Scalar, Vector}; /// /// The goal of this type is to eventually implement `Eq` and `Hash`, making it /// easier to work with vectors. This is a work in progress. -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Ord, PartialOrd)] pub struct Point([Scalar; D]); impl Point { diff --git a/src/math/segment.rs b/src/math/segment.rs index 6b0937841..930c58fc6 100644 --- a/src/math/segment.rs +++ b/src/math/segment.rs @@ -1,7 +1,7 @@ use super::Point; /// A line segment, defined by its two end points -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Ord, PartialOrd)] pub struct Segment { pub a: Point, pub b: Point, diff --git a/src/math/triangle.rs b/src/math/triangle.rs index d1f230da4..dbbb797b7 100644 --- a/src/math/triangle.rs +++ b/src/math/triangle.rs @@ -1,7 +1,7 @@ use super::Point; /// A triangle -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Ord, PartialOrd)] pub struct Triangle { pub a: Point<3>, pub b: Point<3>, diff --git a/src/math/vector.rs b/src/math/vector.rs index 26d78cc4a..3893d0296 100644 --- a/src/math/vector.rs +++ b/src/math/vector.rs @@ -12,7 +12,7 @@ use super::Scalar; /// /// The goal of this type is to eventually implement `Eq` and `Hash`, making it /// easier to work with vectors. This is a work in progress. -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Ord, PartialOrd)] pub struct Vector([Scalar; D]); impl Vector {