Skip to content

Commit f102801

Browse files
authored
Fix incorrect implementations of the Hash and PartialEq traits on Table<T> (#3306)
Fix incorrect implementations of the Hash and PartialEq traits on Table
1 parent 5be9b1f commit f102801

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

node-graph/gcore/src/table.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::bounds::{BoundingBox, RenderBoundingBox};
22
use crate::transform::ApplyTransform;
33
use crate::uuid::NodeId;
44
use crate::{AlphaBlending, math::quad::Quad};
5-
use dyn_any::StaticType;
5+
use dyn_any::{StaticType, StaticTypeSized};
66
use glam::DAffine2;
77
use std::hash::Hash;
88

@@ -203,6 +203,18 @@ impl<T: Hash> Hash for Table<T> {
203203
for element in &self.element {
204204
element.hash(state);
205205
}
206+
for transform in &self.transform {
207+
transform.to_cols_array().map(|x| x.to_bits()).hash(state);
208+
}
209+
for alpha_blending in &self.alpha_blending {
210+
alpha_blending.hash(state);
211+
}
212+
}
213+
}
214+
215+
impl<T: PartialEq> PartialEq for Table<T> {
216+
fn eq(&self, other: &Self) -> bool {
217+
self.element == other.element && self.transform == other.transform && self.alpha_blending == other.alpha_blending
206218
}
207219
}
208220

@@ -220,14 +232,8 @@ impl<T> ApplyTransform for Table<T> {
220232
}
221233
}
222234

223-
impl<T: PartialEq> PartialEq for Table<T> {
224-
fn eq(&self, other: &Self) -> bool {
225-
self.element.len() == other.element.len() && { self.element.iter().zip(other.element.iter()).all(|(a, b)| a == b) }
226-
}
227-
}
228-
229-
unsafe impl<T: StaticType + 'static> StaticType for Table<T> {
230-
type Static = Table<T>;
235+
unsafe impl<T: StaticTypeSized> StaticType for Table<T> {
236+
type Static = Table<T::Static>;
231237
}
232238

233239
impl<T> FromIterator<TableRow<T>> for Table<T> {

0 commit comments

Comments
 (0)