-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the
SystemParam
derive macro more flexible (#6694)
# Objective Currently, the `SystemParam` derive forces you to declare the lifetime parameters `<'w, 's>`, even if you don't use them. If you don't follow this structure, the error message is quite nasty. ### Example (before): ```rust #[derive(SystemParam)] pub struct EventWriter<'w, 's, E: Event> { events: ResMut<'w, Events<E>>, // The derive forces us to declare the `'s` lifetime even though we don't use it, // so we have to add this `PhantomData` to please rustc. #[system_param(ignore)] _marker: PhantomData<&'s ()>, } ``` ## Solution * Allow the user to omit either lifetime. * Emit a descriptive error if any lifetimes used are invalid. ### Example (after): ```rust #[derive(SystemParam)] pub struct EventWriter<'w, E: Event> { events: ResMut<'w, Events<E>>, } ``` --- ## Changelog * The `SystemParam` derive is now more flexible, allowing you to omit unused lifetime parameters.
- Loading branch information
Showing
3 changed files
with
52 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 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 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