impl Eq
/PartialEq
for MeshMaterial{2|3}d
(#17990)
# Objective `Eq`/`PartialEq` are currently implemented for `MeshMaterial{2|3}d` only through the derive macro. Since we don't have perfect derive yet, the impls are only present for `M: Eq` and `M: PartialEq`. On the other hand, I want to be able to compare material components for my toy reactivity project. ## Solution Switch to manual `Eq`/`PartialEq` impl. ## Testing Boy I hope this didn't break anything!
This commit is contained in:
parent
8122b35ce2
commit
2953db7f8f
@ -36,7 +36,7 @@ use derive_more::derive::From;
|
||||
/// ));
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Component, Clone, Debug, Deref, DerefMut, Reflect, PartialEq, Eq, From)]
|
||||
#[derive(Component, Clone, Debug, Deref, DerefMut, Reflect, From)]
|
||||
#[reflect(Component, Default)]
|
||||
pub struct MeshMaterial3d<M: Material>(pub Handle<M>);
|
||||
|
||||
@ -46,6 +46,14 @@ impl<M: Material> Default for MeshMaterial3d<M> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<M: Material> PartialEq for MeshMaterial3d<M> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.0 == other.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<M: Material> Eq for MeshMaterial3d<M> {}
|
||||
|
||||
impl<M: Material> From<MeshMaterial3d<M>> for AssetId<M> {
|
||||
fn from(material: MeshMaterial3d<M>) -> Self {
|
||||
material.id()
|
||||
|
@ -186,7 +186,7 @@ pub trait Material2d: AsBindGroup + Asset + Clone + Sized {
|
||||
/// ```
|
||||
///
|
||||
/// [`MeshMaterial2d`]: crate::MeshMaterial2d
|
||||
#[derive(Component, Clone, Debug, Deref, DerefMut, Reflect, PartialEq, Eq, From)]
|
||||
#[derive(Component, Clone, Debug, Deref, DerefMut, Reflect, From)]
|
||||
#[reflect(Component, Default)]
|
||||
pub struct MeshMaterial2d<M: Material2d>(pub Handle<M>);
|
||||
|
||||
@ -196,6 +196,14 @@ impl<M: Material2d> Default for MeshMaterial2d<M> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<M: Material2d> PartialEq for MeshMaterial2d<M> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.0 == other.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<M: Material2d> Eq for MeshMaterial2d<M> {}
|
||||
|
||||
impl<M: Material2d> From<MeshMaterial2d<M>> for AssetId<M> {
|
||||
fn from(material: MeshMaterial2d<M>) -> Self {
|
||||
material.id()
|
||||
|
Loading…
Reference in New Issue
Block a user