Skip to content

Commit

Permalink
Add std derives to SystemParam types (#16785)
Browse files Browse the repository at this point in the history
# Objective

- Use `Clone` on `SystemParam`, when applicable, in a generic context.

## Solution

-  Add some derives

## Testing

- I ran `cargo test` once.
- I didn't even look at the output.

---------

Co-authored-by: François Mockers <[email protected]>
  • Loading branch information
spectria-limina and mockersf authored Jan 14, 2025
1 parent 83b2265 commit 4dfa877
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/bevy_ecs/src/system/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub unsafe trait SystemParamBuilder<P: SystemParam>: Sized {
/// .build_state(&mut world)
/// .build_system(my_system);
/// ```
#[derive(Default, Debug, Copy, Clone)]
#[derive(Default, Debug, Clone)]
pub struct ParamBuilder;

// SAFETY: Calls `SystemParam::init_state`
Expand Down Expand Up @@ -257,6 +257,7 @@ unsafe impl<'w, 's, D: QueryData + 'static, F: QueryFilter + 'static>
/// .build_state(&mut world)
/// .build_system(|query: Vec<Query<()>>| {});
/// ```
#[derive(Clone)]
pub struct QueryParamBuilder<T>(T);

impl<T> QueryParamBuilder<T> {
Expand Down Expand Up @@ -401,6 +402,7 @@ unsafe impl<P: SystemParam, B: SystemParamBuilder<P>> SystemParamBuilder<Vec<P>>
/// set.for_each(|mut query| for mut health in query.iter_mut() {});
/// }
/// ```
#[derive(Debug, Default, Clone)]
pub struct ParamSetBuilder<T>(pub T);

macro_rules! impl_param_set_builder_tuple {
Expand Down Expand Up @@ -520,6 +522,7 @@ unsafe impl<'a, 'w, 's> SystemParamBuilder<DynSystemParam<'w, 's>> for DynParamB
/// });
/// # world.run_system_once(system);
/// ```
#[derive(Default, Debug, Clone)]
pub struct LocalBuilder<T>(pub T);

// SAFETY: `Local` performs no world access.
Expand All @@ -537,6 +540,7 @@ unsafe impl<'s, T: FromWorld + Send + 'static> SystemParamBuilder<Local<'s, T>>

/// A [`SystemParamBuilder`] for a [`FilteredResources`].
/// See the [`FilteredResources`] docs for examples.
#[derive(Clone)]
pub struct FilteredResourcesParamBuilder<T>(T);

impl<T> FilteredResourcesParamBuilder<T> {
Expand Down Expand Up @@ -600,6 +604,7 @@ unsafe impl<'w, 's, T: FnOnce(&mut FilteredResourcesBuilder)>

/// A [`SystemParamBuilder`] for a [`FilteredResourcesMut`].
/// See the [`FilteredResourcesMut`] docs for examples.
#[derive(Clone)]
pub struct FilteredResourcesMutParamBuilder<T>(T);

impl<T> FilteredResourcesMutParamBuilder<T> {
Expand Down

0 comments on commit 4dfa877

Please sign in to comment.