From f4d28dd3c3f46627085126d9251c0c94f749b12b Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 5 Sep 2024 15:43:02 -0700 Subject: [PATCH] use derive macros --- fixed_wide_vectors/src/macros/matrix.rs | 14 -------------- fixed_wide_vectors/src/macros/vector.rs | 14 -------------- fixed_wide_vectors/src/matrix.rs | 2 +- fixed_wide_vectors/src/vector.rs | 2 +- 4 files changed, 2 insertions(+), 30 deletions(-) diff --git a/fixed_wide_vectors/src/macros/matrix.rs b/fixed_wide_vectors/src/macros/matrix.rs index 05a213f..1964dff 100644 --- a/fixed_wide_vectors/src/macros/matrix.rs +++ b/fixed_wide_vectors/src/macros/matrix.rs @@ -32,20 +32,6 @@ macro_rules! impl_matrix { } } - impl PartialEq for Matrix{ - fn eq(&self,other:&Self)->bool{ - self.array==other.array - } - } - - impl Eq for Matrix{} - - impl core::hash::Hash for Matrix{ - fn hash(&self,state:&mut H){ - self.array.hash(state); - } - } - impl Default for Matrix{ fn default()->Self{ Self{ diff --git a/fixed_wide_vectors/src/macros/vector.rs b/fixed_wide_vectors/src/macros/vector.rs index 24fe199..2ea5dfb 100644 --- a/fixed_wide_vectors/src/macros/vector.rs +++ b/fixed_wide_vectors/src/macros/vector.rs @@ -40,20 +40,6 @@ macro_rules! impl_vector { } } - impl PartialEq for Vector{ - fn eq(&self,other:&Self)->bool{ - self.array==other.array - } - } - - impl Eq for Vector{} - - impl core::hash::Hash for Vector{ - fn hash(&self,state:&mut H){ - self.array.hash(state); - } - } - impl Default for Vector{ fn default()->Self{ Self{ diff --git a/fixed_wide_vectors/src/matrix.rs b/fixed_wide_vectors/src/matrix.rs index a4ec526..4ca1236 100644 --- a/fixed_wide_vectors/src/matrix.rs +++ b/fixed_wide_vectors/src/matrix.rs @@ -1,4 +1,4 @@ -#[derive(Clone,Copy)] +#[derive(Clone,Copy,Hash,Eq,PartialEq)] pub struct Matrix{ pub(crate) array:[[T;Y];X], } diff --git a/fixed_wide_vectors/src/vector.rs b/fixed_wide_vectors/src/vector.rs index b706670..ffea1f0 100644 --- a/fixed_wide_vectors/src/vector.rs +++ b/fixed_wide_vectors/src/vector.rs @@ -1,4 +1,4 @@ -#[derive(Clone,Copy)] +#[derive(Clone,Copy,Hash,Eq,PartialEq)] pub struct Vector{ pub(crate) array:[T;N], }