bevy/crates/bevy_ecs/src/system
Alice Cecile 44ad3bf62b
Move Resource trait to its own file (#17469)
# Objective

`bevy_ecs`'s `system` module is something of a grab bag, and *very*
large. This is particularly true for the `system_param` module, which is
more than 2k lines long!

While it could be defensible to put `Res` and `ResMut` there (lol no
they're in change_detection.rs, obviously), it doesn't make any sense to
put the `Resource` trait there. This is confusing to navigate (and
painful to work on and review).

## Solution

- Create a root level `bevy_ecs/resource.rs` module to mirror
`bevy_ecs/component.rs`
- move the `Resource` trait to that module
- move the `Resource` derive macro to that module as well (Rust really
likes when you pun on the names of the derive macro and trait and put
them in the same path)
- fix all of the imports

## Notes to reviewers

- We could probably move more stuff into here, but I wanted to keep this
PR as small as possible given the absurd level of import changes.
- This PR is ground work for my upcoming attempts to store resource data
on components (resources-as-entities). Splitting this code out will make
the work and review a bit easier, and is the sort of overdue refactor
that's good to do as part of more meaningful work.

## Testing

cargo build works!

## Migration Guide

`bevy_ecs::system::Resource` has been moved to
`bevy_ecs::resource::Resource`.
2025-01-21 19:47:08 +00:00
..
commands Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
adapter_system.rs Add no_std support to bevy_ecs (#16758) 2024-12-17 21:40:36 +00:00
builder.rs Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
combinator.rs bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
exclusive_function_system.rs bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
exclusive_system_param.rs bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
function_system.rs bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
input.rs bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
mod.rs Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
observer_system.rs Add usage notes for the IntoX family of ECS traits (#17379) 2025-01-17 01:18:22 +00:00
query.rs docs: enhance documentation in query.rs to clarify borrowing rules (#17370) 2025-01-20 21:31:20 +00:00
schedule_system.rs Convert to fallible system in IntoSystemConfigs (#17051) 2024-12-31 00:39:29 +00:00
system_name.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
system_param.rs Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
system_registry.rs Renamed members of ParamWarnPolicy to reflect new behaviour. (#17311) 2025-01-12 05:40:04 +00:00
system.rs bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00