Open bushrat011899 opened 2 weeks ago
I think the function is supposed to stay deprecated, not removed. It's just bevy itself needs to not use the function. It can be removed in 0.16.
The migration guide is written relative to main. If this is for 0.15, should it be written relative to 0.14 instead? In 0.14, there were separate component_read()
, component_writes()
, and component_reads_and_writes()
methods that returned plain impl Iterator
s, and they returned empty iterators when the result would have been unbounded.
I think the function is supposed to stay deprecated, not removed. It's just bevy itself needs to not use the function. It can be removed in 0.16.
I decided to remove them entirely, since they don't actually work as users expect them to in their current form. Basically, the breaking change already happened, so we might as well see it through to a meaningful replacement.
The migration guide is written relative to main. If this is for 0.15, should it be written relative to 0.14 instead? In 0.14, there were separate
component_read()
,component_writes()
, andcomponent_reads_and_writes()
methods that returned plainimpl Iterator
s, and they returned empty iterators when the result would have been unbounded.
I've updated the migration guide to explicitly reference the 0.14 state of these methods, thanks for calling that out! To help, I've provided an implementation of an extension trait which should allow the migration to be a drop-in replacement.
I would prefer to just undeprecate it for the 0.15, to have more time for a proper fix https://github.com/bevyengine/bevy/pull/16357
Closed in favour of #16357
Oh ok sorry I misunderstood! I'll reopen but just remove it from the 0.15 milestone.
Objective
Solution
component_reads_and_writes
andcomponent_writes
withtry_iter_component_access
.Testing
dynamic
example to confirm behaviour is unchanged.Migration Guide
The following methods (some removed in previous PRs) are now replaced by
Access::try_iter_component_access
:Access::component_reads_and_writes
Access::component_reads
Access::component_writes
As
try_iter_component_access
returns aResult
, you'll now need to handle the failing case (e.g.,unwrap()
). There is currently a single failure mode,UnboundedAccess
, which occurs when theAccess
is for allComponents
except certain exclusions. Since this list is infinite, there is no meaningful way forAccess
to provide an iterator. Instead, get a list of components (e.g., from theComponents
structure) and iterate over that instead, filtering usingAccess::has_component_read
,Access::has_component_write
, etc.Additionally, you'll need to
filter_map
the accesses based on which method you're attempting to replace:Access::component_reads_and_writes
->Exclusive(_) | Shared(_)
Access::component_reads
->Shared(_)
Access::component_writes
->Exclusive(_)
To ease migration, please consider the below extension trait which you can include in your project:
Please take note of the use of
expect(...)
in these methods. You should consider using these as a starting point for a more appropriate migration based on your specific needs.Notes
Access
is bounded or unbounded (unbounded occurring with inverted component sets). If bounded, will return an iterator of every item and its access level. I believe this makes sense without exposing implementation details aroundAccess
.enum
ComponentAccessKind<T>
, eitherArchetypical
,Shared
, orExclusive
. As a convenience, thisenum
has a methodindex
to get the innerT
value without a match statement. It does add more code, but the API is clearer.QueryBuilder
this new method simplifies several pieces of logic without changing behaviour.QueryState
the logic is simplified and the amount of iteration is reduced, potentially improving performance.dynamic
example it has identical behaviour, with the inversion footgun explicitly highlighted by anunwrap
.