@@ -12,7 +12,7 @@ use crate::{
12
12
world:: { World , WorldId } ,
13
13
} ;
14
14
use bevy_ecs_macros:: all_tuples;
15
- use std:: { borrow:: Cow , fmt:: Debug , hash :: Hash , marker:: PhantomData } ;
15
+ use std:: { borrow:: Cow , fmt:: Debug , marker:: PhantomData } ;
16
16
17
17
/// The metadata of a [`System`].
18
18
#[ derive( Clone ) ]
@@ -452,41 +452,28 @@ where
452
452
/// A [`SystemLabel`] that was automatically generated for a system on the basis of its `TypeId`.
453
453
pub struct SystemTypeIdLabel < T : ' static > ( PhantomData < fn ( ) -> T > ) ;
454
454
455
+ impl < T : ' static > SystemLabel for SystemTypeIdLabel < T > {
456
+ #[ inline]
457
+ fn as_str ( & self ) -> & ' static str {
458
+ std:: any:: type_name :: < T > ( )
459
+ }
460
+ }
461
+
455
462
impl < T > Debug for SystemTypeIdLabel < T > {
456
463
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
457
464
f. debug_tuple ( "SystemTypeIdLabel" )
458
465
. field ( & std:: any:: type_name :: < T > ( ) )
459
466
. finish ( )
460
467
}
461
468
}
462
- impl < T > Hash for SystemTypeIdLabel < T > {
463
- fn hash < H : std:: hash:: Hasher > ( & self , _state : & mut H ) {
464
- // All SystemTypeIds of a given type are the same.
465
- }
466
- }
469
+
467
470
impl < T > Clone for SystemTypeIdLabel < T > {
468
471
fn clone ( & self ) -> Self {
469
- Self ( PhantomData )
472
+ * self
470
473
}
471
474
}
472
-
473
475
impl < T > Copy for SystemTypeIdLabel < T > { }
474
476
475
- impl < T > PartialEq for SystemTypeIdLabel < T > {
476
- #[ inline]
477
- fn eq ( & self , _other : & Self ) -> bool {
478
- // All labels of a given type are equal, as they will all have the same type id
479
- true
480
- }
481
- }
482
- impl < T > Eq for SystemTypeIdLabel < T > { }
483
-
484
- impl < T > SystemLabel for SystemTypeIdLabel < T > {
485
- fn as_str ( & self ) -> & ' static str {
486
- std:: any:: type_name :: < T > ( )
487
- }
488
- }
489
-
490
477
/// A trait implemented for all functions that can be used as [`System`]s.
491
478
///
492
479
/// This trait can be useful for making your own systems which accept other systems,
@@ -612,24 +599,21 @@ all_tuples!(impl_system_function, 0, 16, F);
612
599
/// Used to implicitly convert systems to their default labels. For example, it will convert
613
600
/// "system functions" to their [`SystemTypeIdLabel`].
614
601
pub trait AsSystemLabel < Marker > {
615
- type SystemLabel : SystemLabel ;
616
- fn as_system_label ( & self ) -> Self :: SystemLabel ;
602
+ fn as_system_label ( & self ) -> SystemLabelId ;
617
603
}
618
604
619
605
impl < In , Out , Param : SystemParam , Marker , T : SystemParamFunction < In , Out , Param , Marker > >
620
606
AsSystemLabel < ( In , Out , Param , Marker ) > for T
621
607
{
622
- type SystemLabel = SystemTypeIdLabel < Self > ;
623
-
624
- fn as_system_label ( & self ) -> Self :: SystemLabel {
625
- SystemTypeIdLabel ( PhantomData :: < fn ( ) -> Self > )
608
+ #[ inline]
609
+ fn as_system_label ( & self ) -> SystemLabelId {
610
+ SystemTypeIdLabel :: < T > ( PhantomData ) . as_label ( )
626
611
}
627
612
}
628
613
629
- impl < T : SystemLabel + Clone > AsSystemLabel < ( ) > for T {
630
- type SystemLabel = T ;
631
-
632
- fn as_system_label ( & self ) -> Self :: SystemLabel {
633
- self . clone ( )
614
+ impl < T : SystemLabel > AsSystemLabel < ( ) > for T {
615
+ #[ inline]
616
+ fn as_system_label ( & self ) -> SystemLabelId {
617
+ self . as_label ( )
634
618
}
635
619
}
0 commit comments