@@ -278,16 +278,14 @@ pub type ROQueryItem<'w, D> = QueryItem<'w, <D as QueryData>::ReadOnly>;
278
278
/// `update_component_access` and `update_archetype_component_access` do nothing.
279
279
/// This is sound because `fetch` does not access components.
280
280
unsafe impl WorldQuery for Entity {
281
- type Fetch < ' w > = ( ) ;
282
281
type Item < ' w > = Entity ;
282
+ type Fetch < ' w > = ( ) ;
283
283
type State = ( ) ;
284
284
285
285
fn shrink < ' wlong : ' wshort , ' wshort > ( item : Self :: Item < ' wlong > ) -> Self :: Item < ' wshort > {
286
286
item
287
287
}
288
288
289
- const IS_DENSE : bool = true ;
290
-
291
289
unsafe fn init_fetch < ' w > (
292
290
_world : UnsafeWorldCell < ' w > ,
293
291
_state : & Self :: State ,
@@ -296,6 +294,8 @@ unsafe impl WorldQuery for Entity {
296
294
) -> Self :: Fetch < ' w > {
297
295
}
298
296
297
+ const IS_DENSE : bool = true ;
298
+
299
299
#[ inline]
300
300
unsafe fn set_archetype < ' w > (
301
301
_fetch : & mut Self :: Fetch < ' w > ,
@@ -350,16 +350,14 @@ unsafe impl ReadOnlyQueryData for Entity {}
350
350
/// This is sound because `update_component_access` and `update_archetype_component_access` set read access for all components and panic when appropriate.
351
351
/// Filters are unchanged.
352
352
unsafe impl < ' a > WorldQuery for EntityRef < ' a > {
353
- type Fetch < ' w > = UnsafeWorldCell < ' w > ;
354
353
type Item < ' w > = EntityRef < ' w > ;
354
+ type Fetch < ' w > = UnsafeWorldCell < ' w > ;
355
355
type State = ( ) ;
356
356
357
357
fn shrink < ' wlong : ' wshort , ' wshort > ( item : Self :: Item < ' wlong > ) -> Self :: Item < ' wshort > {
358
358
item
359
359
}
360
360
361
- const IS_DENSE : bool = true ;
362
-
363
361
unsafe fn init_fetch < ' w > (
364
362
world : UnsafeWorldCell < ' w > ,
365
363
_state : & Self :: State ,
@@ -369,6 +367,8 @@ unsafe impl<'a> WorldQuery for EntityRef<'a> {
369
367
world
370
368
}
371
369
370
+ const IS_DENSE : bool = true ;
371
+
372
372
#[ inline]
373
373
unsafe fn set_archetype < ' w > (
374
374
_fetch : & mut Self :: Fetch < ' w > ,
@@ -432,16 +432,14 @@ unsafe impl ReadOnlyQueryData for EntityRef<'_> {}
432
432
433
433
/// SAFETY: The accesses of `Self::ReadOnly` are a subset of the accesses of `Self`
434
434
unsafe impl < ' a > WorldQuery for EntityMut < ' a > {
435
- type Fetch < ' w > = UnsafeWorldCell < ' w > ;
436
435
type Item < ' w > = EntityMut < ' w > ;
436
+ type Fetch < ' w > = UnsafeWorldCell < ' w > ;
437
437
type State = ( ) ;
438
438
439
439
fn shrink < ' wlong : ' wshort , ' wshort > ( item : Self :: Item < ' wlong > ) -> Self :: Item < ' wshort > {
440
440
item
441
441
}
442
442
443
- const IS_DENSE : bool = true ;
444
-
445
443
unsafe fn init_fetch < ' w > (
446
444
world : UnsafeWorldCell < ' w > ,
447
445
_state : & Self :: State ,
@@ -451,6 +449,8 @@ unsafe impl<'a> WorldQuery for EntityMut<'a> {
451
449
world
452
450
}
453
451
452
+ const IS_DENSE : bool = true ;
453
+
454
454
#[ inline]
455
455
unsafe fn set_archetype < ' w > (
456
456
_fetch : & mut Self :: Fetch < ' w > ,
@@ -530,21 +530,14 @@ impl<T> Copy for ReadFetch<'_, T> {}
530
530
/// `update_component_access` adds a `With` filter for a component.
531
531
/// This is sound because `matches_component_set` returns whether the set contains that component.
532
532
unsafe impl < T : Component > WorldQuery for & T {
533
- type Fetch < ' w > = ReadFetch < ' w , T > ;
534
533
type Item < ' w > = & ' w T ;
534
+ type Fetch < ' w > = ReadFetch < ' w , T > ;
535
535
type State = ComponentId ;
536
536
537
537
fn shrink < ' wlong : ' wshort , ' wshort > ( item : & ' wlong T ) -> & ' wshort T {
538
538
item
539
539
}
540
540
541
- const IS_DENSE : bool = {
542
- match T :: Storage :: STORAGE_TYPE {
543
- StorageType :: Table => true ,
544
- StorageType :: SparseSet => false ,
545
- }
546
- } ;
547
-
548
541
#[ inline]
549
542
unsafe fn init_fetch < ' w > (
550
543
world : UnsafeWorldCell < ' w > ,
@@ -568,6 +561,13 @@ unsafe impl<T: Component> WorldQuery for &T {
568
561
}
569
562
}
570
563
564
+ const IS_DENSE : bool = {
565
+ match T :: Storage :: STORAGE_TYPE {
566
+ StorageType :: Table => true ,
567
+ StorageType :: SparseSet => false ,
568
+ }
569
+ } ;
570
+
571
571
#[ inline]
572
572
unsafe fn set_archetype < ' w > (
573
573
fetch : & mut ReadFetch < ' w , T > ,
@@ -686,21 +686,14 @@ impl<T> Copy for RefFetch<'_, T> {}
686
686
/// `update_component_access` adds a `With` filter for a component.
687
687
/// This is sound because `matches_component_set` returns whether the set contains that component.
688
688
unsafe impl < ' __w , T : Component > WorldQuery for Ref < ' __w , T > {
689
- type Fetch < ' w > = RefFetch < ' w , T > ;
690
689
type Item < ' w > = Ref < ' w , T > ;
690
+ type Fetch < ' w > = RefFetch < ' w , T > ;
691
691
type State = ComponentId ;
692
692
693
693
fn shrink < ' wlong : ' wshort , ' wshort > ( item : Ref < ' wlong , T > ) -> Ref < ' wshort , T > {
694
694
item
695
695
}
696
696
697
- const IS_DENSE : bool = {
698
- match T :: Storage :: STORAGE_TYPE {
699
- StorageType :: Table => true ,
700
- StorageType :: SparseSet => false ,
701
- }
702
- } ;
703
-
704
697
#[ inline]
705
698
unsafe fn init_fetch < ' w > (
706
699
world : UnsafeWorldCell < ' w > ,
@@ -723,6 +716,13 @@ unsafe impl<'__w, T: Component> WorldQuery for Ref<'__w, T> {
723
716
}
724
717
}
725
718
719
+ const IS_DENSE : bool = {
720
+ match T :: Storage :: STORAGE_TYPE {
721
+ StorageType :: Table => true ,
722
+ StorageType :: SparseSet => false ,
723
+ }
724
+ } ;
725
+
726
726
#[ inline]
727
727
unsafe fn set_archetype < ' w > (
728
728
fetch : & mut RefFetch < ' w , T > ,
@@ -853,21 +853,14 @@ impl<T> Copy for WriteFetch<'_, T> {}
853
853
/// `update_component_access` adds a `With` filter for a component.
854
854
/// This is sound because `matches_component_set` returns whether the set contains that component.
855
855
unsafe impl < ' __w , T : Component > WorldQuery for & ' __w mut T {
856
- type Fetch < ' w > = WriteFetch < ' w , T > ;
857
856
type Item < ' w > = Mut < ' w , T > ;
857
+ type Fetch < ' w > = WriteFetch < ' w , T > ;
858
858
type State = ComponentId ;
859
859
860
860
fn shrink < ' wlong : ' wshort , ' wshort > ( item : Mut < ' wlong , T > ) -> Mut < ' wshort , T > {
861
861
item
862
862
}
863
863
864
- const IS_DENSE : bool = {
865
- match T :: Storage :: STORAGE_TYPE {
866
- StorageType :: Table => true ,
867
- StorageType :: SparseSet => false ,
868
- }
869
- } ;
870
-
871
864
#[ inline]
872
865
unsafe fn init_fetch < ' w > (
873
866
world : UnsafeWorldCell < ' w > ,
@@ -890,6 +883,13 @@ unsafe impl<'__w, T: Component> WorldQuery for &'__w mut T {
890
883
}
891
884
}
892
885
886
+ const IS_DENSE : bool = {
887
+ match T :: Storage :: STORAGE_TYPE {
888
+ StorageType :: Table => true ,
889
+ StorageType :: SparseSet => false ,
890
+ }
891
+ } ;
892
+
893
893
#[ inline]
894
894
unsafe fn set_archetype < ' w > (
895
895
fetch : & mut WriteFetch < ' w , T > ,
@@ -1009,16 +1009,14 @@ impl<T: WorldQuery> Clone for OptionFetch<'_, T> {
1009
1009
/// This is sound because `update_component_access` and `update_archetype_component_access` add the same accesses as `T`.
1010
1010
/// Filters are unchanged.
1011
1011
unsafe impl < T : WorldQuery > WorldQuery for Option < T > {
1012
- type Fetch < ' w > = OptionFetch < ' w , T > ;
1013
1012
type Item < ' w > = Option < T :: Item < ' w > > ;
1013
+ type Fetch < ' w > = OptionFetch < ' w , T > ;
1014
1014
type State = T :: State ;
1015
1015
1016
1016
fn shrink < ' wlong : ' wshort , ' wshort > ( item : Self :: Item < ' wlong > ) -> Self :: Item < ' wshort > {
1017
1017
item. map ( T :: shrink)
1018
1018
}
1019
1019
1020
- const IS_DENSE : bool = T :: IS_DENSE ;
1021
-
1022
1020
#[ inline]
1023
1021
unsafe fn init_fetch < ' w > (
1024
1022
world : UnsafeWorldCell < ' w > ,
@@ -1032,6 +1030,8 @@ unsafe impl<T: WorldQuery> WorldQuery for Option<T> {
1032
1030
}
1033
1031
}
1034
1032
1033
+ const IS_DENSE : bool = T :: IS_DENSE ;
1034
+
1035
1035
#[ inline]
1036
1036
unsafe fn set_archetype < ' w > (
1037
1037
fetch : & mut OptionFetch < ' w , T > ,
@@ -1168,21 +1168,14 @@ pub struct Has<T>(PhantomData<T>);
1168
1168
/// `update_component_access` and `update_archetype_component_access` do nothing.
1169
1169
/// This is sound because `fetch` does not access components.
1170
1170
unsafe impl < T : Component > WorldQuery for Has < T > {
1171
- type Fetch < ' w > = bool ;
1172
1171
type Item < ' w > = bool ;
1172
+ type Fetch < ' w > = bool ;
1173
1173
type State = ComponentId ;
1174
1174
1175
1175
fn shrink < ' wlong : ' wshort , ' wshort > ( item : Self :: Item < ' wlong > ) -> Self :: Item < ' wshort > {
1176
1176
item
1177
1177
}
1178
1178
1179
- const IS_DENSE : bool = {
1180
- match T :: Storage :: STORAGE_TYPE {
1181
- StorageType :: Table => true ,
1182
- StorageType :: SparseSet => false ,
1183
- }
1184
- } ;
1185
-
1186
1179
#[ inline]
1187
1180
unsafe fn init_fetch < ' w > (
1188
1181
_world : UnsafeWorldCell < ' w > ,
@@ -1193,6 +1186,13 @@ unsafe impl<T: Component> WorldQuery for Has<T> {
1193
1186
false
1194
1187
}
1195
1188
1189
+ const IS_DENSE : bool = {
1190
+ match T :: Storage :: STORAGE_TYPE {
1191
+ StorageType :: Table => true ,
1192
+ StorageType :: SparseSet => false ,
1193
+ }
1194
+ } ;
1195
+
1196
1196
#[ inline]
1197
1197
unsafe fn set_archetype < ' w > (
1198
1198
fetch : & mut Self :: Fetch < ' w > ,
@@ -1408,14 +1408,12 @@ pub struct NopWorldQuery<D: QueryData>(PhantomData<D>);
1408
1408
/// `update_component_access` and `update_archetype_component_access` do nothing.
1409
1409
/// This is sound because `fetch` does not access components.
1410
1410
unsafe impl < D : QueryData > WorldQuery for NopWorldQuery < D > {
1411
- type Fetch < ' w > = ( ) ;
1412
1411
type Item < ' w > = ( ) ;
1412
+ type Fetch < ' w > = ( ) ;
1413
1413
type State = D :: State ;
1414
1414
1415
1415
fn shrink < ' wlong : ' wshort , ' wshort > ( _: ( ) ) { }
1416
1416
1417
- const IS_DENSE : bool = D :: IS_DENSE ;
1418
-
1419
1417
#[ inline( always) ]
1420
1418
unsafe fn init_fetch (
1421
1419
_world : UnsafeWorldCell ,
@@ -1425,6 +1423,8 @@ unsafe impl<D: QueryData> WorldQuery for NopWorldQuery<D> {
1425
1423
) {
1426
1424
}
1427
1425
1426
+ const IS_DENSE : bool = D :: IS_DENSE ;
1427
+
1428
1428
#[ inline( always) ]
1429
1429
unsafe fn set_archetype (
1430
1430
_fetch : & mut ( ) ,
0 commit comments