Skip to content

Commit 6aedb25

Browse files
committed
Cleanup FromResources (#2601)
## Objective - Clean up remaining references to the trait `FromResources`, which was replaced in favor of `FromWorld` during the ECS rework. ## Solution - Remove the derive macro for `FromResources` - Change doc references of `FromResources` to `FromWorld` (this is the first item in #2576)
1 parent 5eeba15 commit 6aedb25

File tree

7 files changed

+9
-51
lines changed

7 files changed

+9
-51
lines changed

crates/bevy_app/src/app.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl App {
343343
/// A resource in Bevy represents globally unique data. Resources must be added to Bevy Apps
344344
/// before using them. This happens with [`App::insert_resource`].
345345
///
346-
/// See also `init_resource` for resources that implement `Default` or [`FromResources`].
346+
/// See also `init_resource` for resources that implement `Default` or [`FromWorld`].
347347
///
348348
/// ## Example
349349
/// ```
@@ -390,7 +390,7 @@ impl App {
390390

391391
/// Initialize a resource in the current [App], if it does not exist yet
392392
///
393-
/// Adds a resource that implements `Default` or [`FromResources`] trait.
393+
/// Adds a resource that implements `Default` or [`FromWorld`] trait.
394394
/// If the resource already exists, `init_resource` does nothing.
395395
///
396396
/// ## Example

crates/bevy_derive/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,10 @@ mod enum_variant_meta;
77
mod modules;
88
mod render_resource;
99
mod render_resources;
10-
mod resource;
1110
mod shader_defs;
1211

1312
use proc_macro::TokenStream;
1413

15-
/// Derives the FromResources trait. Each field must also implement the FromResources trait or this
16-
/// will fail. FromResources is automatically implemented for types that implement Default.
17-
#[proc_macro_derive(FromResources)]
18-
pub fn derive_from_resources(input: TokenStream) -> TokenStream {
19-
resource::derive_from_resources(input)
20-
}
21-
2214
/// Derives the Bytes trait. Each field must also implements Bytes or this will fail.
2315
#[proc_macro_derive(Bytes)]
2416
pub fn derive_bytes(input: TokenStream) -> TokenStream {

crates/bevy_derive/src/modules.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
pub const BEVY_APP: &str = "bevy_app";
21
pub const BEVY_ASSET: &str = "bevy_asset";
32
pub const BEVY_CORE: &str = "bevy_core";
43
pub const BEVY_RENDER: &str = "bevy_render";

crates/bevy_derive/src/resource.rs

Lines changed: 0 additions & 33 deletions
This file was deleted.

crates/bevy_transform/src/components/parent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl MapEntities for PreviousParent {
5252
}
5353
}
5454

55-
// TODO: Better handle this case see `impl FromResources for Parent`
55+
// TODO: Better handle this case see `impl FromWorld for Parent`
5656
impl FromWorld for PreviousParent {
5757
fn from_world(_world: &mut World) -> Self {
5858
PreviousParent(Entity::new(u32::MAX))

examples/ecs/ecs_guide.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fn main() {
272272
// that :) The plugin below runs our app's "system schedule" once every 5 seconds
273273
// (configured above).
274274
.add_plugin(ScheduleRunnerPlugin::default())
275-
// Resources that implement the Default or FromResources trait can be added like this:
275+
// Resources that implement the Default or FromWorld trait can be added like this:
276276
.init_resource::<GameState>()
277277
// Startup systems run exactly once BEFORE all other systems. These are generally used for
278278
// app initialization code (ex: adding entities and resources)

examples/scene/scene.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ fn main() {
1313
.run();
1414
}
1515

16-
// Registered components must implement the `Reflect` and `FromResources` traits.
16+
// Registered components must implement the `Reflect` and `FromWorld` traits.
1717
// The `Reflect` trait enables serialization, deserialization, and dynamic property access.
1818
// `Reflect` enable a bunch of cool behaviors, so its worth checking out the dedicated `reflect.rs`
19-
// example. The `FromResources` trait determines how your component is constructed when it loads.
19+
// example. The `FromWorld` trait determines how your component is constructed when it loads.
2020
// For simple use cases you can just implement the `Default` trait (which automatically implements
21-
// FromResources). The simplest registered component just needs these two derives:
21+
// FromWorld). The simplest registered component just needs these two derives:
2222
#[derive(Reflect, Default)]
2323
#[reflect(Component)] // this tells the reflect derive to also reflect component behaviors
2424
struct ComponentA {
@@ -27,8 +27,8 @@ struct ComponentA {
2727
}
2828

2929
// Some components have fields that cannot (or should not) be written to scene files. These can be
30-
// ignored with the #[reflect(ignore)] attribute. This is also generally where the `FromResources`
31-
// trait comes into play. `FromResources` gives you access to your App's current ECS `Resources`
30+
// ignored with the #[reflect(ignore)] attribute. This is also generally where the `FromWorld`
31+
// trait comes into play. `FromWorld` gives you access to your App's current ECS `Resources`
3232
// when you construct your component.
3333
#[derive(Reflect)]
3434
#[reflect(Component)]

0 commit comments

Comments
 (0)