Fix incorrect implementations of the Hash and PartialEq traits on Table<T> (#3306)

Fix incorrect implementations of the Hash and PartialEq traits on Table
This commit is contained in:
Dennis Kobert 2025-10-27 15:55:36 +01:00 committed by GitHub
parent 5be9b1fabc
commit f102801059
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 9 deletions

View File

@ -2,7 +2,7 @@ use crate::bounds::{BoundingBox, RenderBoundingBox};
use crate::transform::ApplyTransform; use crate::transform::ApplyTransform;
use crate::uuid::NodeId; use crate::uuid::NodeId;
use crate::{AlphaBlending, math::quad::Quad}; use crate::{AlphaBlending, math::quad::Quad};
use dyn_any::StaticType; use dyn_any::{StaticType, StaticTypeSized};
use glam::DAffine2; use glam::DAffine2;
use std::hash::Hash; use std::hash::Hash;
@ -203,6 +203,18 @@ impl<T: Hash> Hash for Table<T> {
for element in &self.element { for element in &self.element {
element.hash(state); element.hash(state);
} }
for transform in &self.transform {
transform.to_cols_array().map(|x| x.to_bits()).hash(state);
}
for alpha_blending in &self.alpha_blending {
alpha_blending.hash(state);
}
}
}
impl<T: PartialEq> PartialEq for Table<T> {
fn eq(&self, other: &Self) -> bool {
self.element == other.element && self.transform == other.transform && self.alpha_blending == other.alpha_blending
} }
} }
@ -220,14 +232,8 @@ impl<T> ApplyTransform for Table<T> {
} }
} }
impl<T: PartialEq> PartialEq for Table<T> { unsafe impl<T: StaticTypeSized> StaticType for Table<T> {
fn eq(&self, other: &Self) -> bool { type Static = Table<T::Static>;
self.element.len() == other.element.len() && { self.element.iter().zip(other.element.iter()).all(|(a, b)| a == b) }
}
}
unsafe impl<T: StaticType + 'static> StaticType for Table<T> {
type Static = Table<T>;
} }
impl<T> FromIterator<TableRow<T>> for Table<T> { impl<T> FromIterator<TableRow<T>> for Table<T> {