@@ -6,7 +6,7 @@ use std::marker::PhantomData;
6
6
pub use bevy_ecs_macros:: { ScheduleLabel , SystemSet } ;
7
7
use bevy_utils:: define_label;
8
8
use bevy_utils:: intern:: { Interned , Interner , Leak } ;
9
- use bevy_utils:: label:: DynHash ;
9
+ use bevy_utils:: label:: DynEq ;
10
10
11
11
use crate :: system:: {
12
12
ExclusiveSystemParamFunction , IsExclusiveFunctionSystem , IsFunctionSystem , SystemParamFunction ,
@@ -25,7 +25,7 @@ pub type InternedSystemSet = Interned<dyn SystemSet>;
25
25
pub type InternedScheduleLabel = Interned < dyn ScheduleLabel > ;
26
26
27
27
/// Types that identify logical groups of systems.
28
- pub trait SystemSet : DynHash + Debug + Send + Sync + ' static {
28
+ pub trait SystemSet : Debug + Send + Sync + ' static {
29
29
/// Returns `Some` if this system set is a [`SystemTypeSet`].
30
30
fn system_type ( & self ) -> Option < TypeId > {
31
31
None
@@ -39,6 +39,12 @@ pub trait SystemSet: DynHash + Debug + Send + Sync + 'static {
39
39
/// Creates a boxed clone of the label corresponding to this system set.
40
40
fn dyn_clone ( & self ) -> Box < dyn SystemSet > ;
41
41
42
+ /// Casts this value to a form where it can be compared with other type-erased values.
43
+ fn as_dyn_eq ( & self ) -> & dyn DynEq ;
44
+
45
+ /// Feeds this value into the given [`Hasher`].
46
+ fn dyn_hash ( & self , state : & mut dyn Hasher ) ;
47
+
42
48
/// Returns a static reference to a value equal to `self`, if possible.
43
49
/// This method is used to optimize [interning](bevy_utils::intern).
44
50
///
@@ -97,6 +103,14 @@ impl SystemSet for Interned<dyn SystemSet> {
97
103
( * * self ) . dyn_clone ( )
98
104
}
99
105
106
+ fn as_dyn_eq ( & self ) -> & dyn DynEq {
107
+ ( * * self ) . as_dyn_eq ( )
108
+ }
109
+
110
+ fn dyn_hash ( & self , state : & mut dyn Hasher ) {
111
+ ( * * self ) . dyn_hash ( state)
112
+ }
113
+
100
114
fn dyn_static_ref ( & self ) -> Option < & ' static dyn SystemSet > {
101
115
Some ( self . 0 )
102
116
}
@@ -111,7 +125,7 @@ impl SystemSet for Interned<dyn SystemSet> {
111
125
112
126
impl PartialEq for dyn SystemSet {
113
127
fn eq ( & self , other : & Self ) -> bool {
114
- self . dyn_eq ( other. as_dyn_eq ( ) )
128
+ self . as_dyn_eq ( ) . dyn_eq ( other. as_dyn_eq ( ) )
115
129
}
116
130
}
117
131
@@ -187,6 +201,15 @@ impl<T> SystemSet for SystemTypeSet<T> {
187
201
Box :: new ( * self )
188
202
}
189
203
204
+ fn as_dyn_eq ( & self ) -> & dyn DynEq {
205
+ self
206
+ }
207
+
208
+ fn dyn_hash ( & self , mut state : & mut dyn Hasher ) {
209
+ std:: any:: TypeId :: of :: < Self > ( ) . hash ( & mut state) ;
210
+ self . hash ( & mut state) ;
211
+ }
212
+
190
213
fn dyn_static_ref ( & self ) -> Option < & ' static dyn SystemSet > {
191
214
Some ( & Self ( PhantomData ) )
192
215
}
@@ -208,6 +231,15 @@ impl SystemSet for AnonymousSet {
208
231
true
209
232
}
210
233
234
+ fn as_dyn_eq ( & self ) -> & dyn DynEq {
235
+ self
236
+ }
237
+
238
+ fn dyn_hash ( & self , mut state : & mut dyn Hasher ) {
239
+ std:: any:: TypeId :: of :: < Self > ( ) . hash ( & mut state) ;
240
+ self . hash ( & mut state) ;
241
+ }
242
+
211
243
fn dyn_clone ( & self ) -> Box < dyn SystemSet > {
212
244
Box :: new ( * self )
213
245
}
0 commit comments