@@ -3287,6 +3287,24 @@ impl<'a> From<&'a EntityWorldMut<'_>> for FilteredEntityRef<'a> {
3287
3287
}
3288
3288
}
3289
3289
3290
+ impl < ' a , B : Bundle > From < & ' a EntityRefExcept < ' _ , B > > for FilteredEntityRef < ' a > {
3291
+ fn from ( value : & ' a EntityRefExcept < ' _ , B > ) -> Self {
3292
+ // SAFETY:
3293
+ // - The FilteredEntityRef has the same component access as the given EntityRefExcept.
3294
+ unsafe {
3295
+ let mut access = Access :: default ( ) ;
3296
+ access. read_all ( ) ;
3297
+ let components = value. entity . world ( ) . components ( ) ;
3298
+ B :: get_component_ids ( components, & mut |maybe_id| {
3299
+ if let Some ( id) = maybe_id {
3300
+ access. remove_component_read ( id) ;
3301
+ }
3302
+ } ) ;
3303
+ FilteredEntityRef :: new ( value. entity , access)
3304
+ }
3305
+ }
3306
+ }
3307
+
3290
3308
impl PartialEq for FilteredEntityRef < ' _ > {
3291
3309
fn eq ( & self , other : & Self ) -> bool {
3292
3310
self . entity ( ) == other. entity ( )
@@ -3612,6 +3630,24 @@ impl<'a> From<&'a mut EntityWorldMut<'_>> for FilteredEntityMut<'a> {
3612
3630
}
3613
3631
}
3614
3632
3633
+ impl < ' a , B : Bundle > From < & ' a EntityMutExcept < ' _ , B > > for FilteredEntityMut < ' a > {
3634
+ fn from ( value : & ' a EntityMutExcept < ' _ , B > ) -> Self {
3635
+ // SAFETY:
3636
+ // - The FilteredEntityMut has the same component access as the given EntityMutExcept.
3637
+ unsafe {
3638
+ let mut access = Access :: default ( ) ;
3639
+ access. write_all ( ) ;
3640
+ let components = value. entity . world ( ) . components ( ) ;
3641
+ B :: get_component_ids ( components, & mut |maybe_id| {
3642
+ if let Some ( id) = maybe_id {
3643
+ access. remove_component_read ( id) ;
3644
+ }
3645
+ } ) ;
3646
+ FilteredEntityMut :: new ( value. entity , access)
3647
+ }
3648
+ }
3649
+ }
3650
+
3615
3651
impl PartialEq for FilteredEntityMut < ' _ > {
3616
3652
fn eq ( & self , other : & Self ) -> bool {
3617
3653
self . entity ( ) == other. entity ( )
@@ -3826,11 +3862,11 @@ where
3826
3862
}
3827
3863
}
3828
3864
3829
- impl < ' a , B > From < & EntityMutExcept < ' a , B > > for EntityRefExcept < ' a , B >
3865
+ impl < ' a , B > From < & ' a EntityMutExcept < ' _ , B > > for EntityRefExcept < ' a , B >
3830
3866
where
3831
3867
B : Bundle ,
3832
3868
{
3833
- fn from ( entity : & EntityMutExcept < ' a , B > ) -> Self {
3869
+ fn from ( entity : & ' a EntityMutExcept < ' _ , B > ) -> Self {
3834
3870
// SAFETY: All accesses that `EntityRefExcept` provides are also
3835
3871
// accesses that `EntityMutExcept` provides.
3836
3872
unsafe { EntityRefExcept :: new ( entity. entity ) }
0 commit comments