Skip to content

Commit

Permalink
Implement ReadOnlySystemParam for Extract<> (bevyengine#7182)
Browse files Browse the repository at this point in the history
# Objective

- `Extract` does not implement `ReadOnlySystemParam` even though it should.
- Noticed by @hymm on discord: https://discord.com/channels/691052431525675048/749335865876021248/1063535818267963543

## Solution

Implement the trait.
  • Loading branch information
JoJoJet authored and alradish committed Jan 22, 2023
1 parent 84332fe commit f51a7c2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/bevy_render/src/extract_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ pub struct ExtractState<P: SystemParam + 'static> {
main_world_state: <Res<'static, MainWorld> as SystemParam>::State,
}

// SAFETY: only accesses MainWorld resource with read only system params using Res,
// which is initialized in init()
// SAFETY: The only `World` access (`Res<MainWorld>`) is read-only.
unsafe impl<P> ReadOnlySystemParam for Extract<'_, '_, P> where P: ReadOnlySystemParam {}

// SAFETY: The only `World` access is properly registered by `Res<MainWorld>::init_state`.
unsafe impl<P> SystemParam for Extract<'_, '_, P>
where
P: ReadOnlySystemParam,
Expand Down

0 comments on commit f51a7c2

Please sign in to comment.