-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Make Resource trait opt-in, requiring #[derive(Resource)]
#5007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d1235fc
Remove blanket impl of Resource
alice-i-cecile 8fa3677
Add docs for Resource trait
alice-i-cecile 4f03af0
Add derive macro, copying directly from derive(Component) macro
alice-i-cecile b168fe8
Add Resource trait to prelude
alice-i-cecile eb506fa
Weaken Local trait bound to Send + Sync + 'static
alice-i-cecile 24d7c09
Derive resource everywhere
alice-i-cecile cbab3c1
Fix SchedulingEvents test
alice-i-cecile 4f74c94
Manually implement Resource for TypeRegistryArc
alice-i-cecile b314e0a
More trivial derives
alice-i-cecile c232410
Revert safety comment on Local
alice-i-cecile File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -221,9 +221,18 @@ pub struct ParamSetState<T: for<'w, 's> SystemParamFetch<'w, 's>>(T); | |
|
|
||
| impl_param_set!(); | ||
|
|
||
| /// A type that can be inserted into a [`World`](crate::world::World) as a singleton. | ||
| /// | ||
| /// Resources are commonly used to store global collections (like assets or events), | ||
| /// or unique global information (such as the current level or state of the app). | ||
| /// | ||
| /// You can access resource data in systems using the [`Res`] and [`ResMut`] system parameters. | ||
| /// | ||
| /// Only one resource of each type can exist at any given time. | ||
| /// Inserting a duplicate resource will overwrite the existing resource. | ||
|
Comment on lines
+225
to
+233
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is something that is up to the |
||
| pub trait Resource: Send + Sync + 'static {} | ||
|
|
||
| /// Shared borrow of a resource. | ||
| /// Shared borrow of a [`Resource`]. | ||
| /// | ||
| /// See the [`World`] documentation to see the usage of a resource. | ||
| /// | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second paragraph seems too specific to me: mentioning use cases and applications is something more suitable to the book imo. API docs are best suited to describe the item itself.
This description also does not illustrate how to insert a resource to the world (i.e.
World::init_resourceorWorld::insert_resource). I would avoid mentioning theAppmethods though, as they are not defined from thebevy_ecsperspective.