-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Merged by Bors] - Conversion of ResMut
and NonSendMut
to Mut
#5438
Conversation
Add a new `into_mut()` method allowing to convert a `ResMut` or `NonSendMut` into a simple `Mut`. This enables treating components and resources equally, which can simplify the implementation of some systems where only the change detection feature is relevant and not the kind of object (resource or component).
I like the idea! IMO this should just be a |
bors r+ |
# Objective Enable treating components and resources equally, which can simplify the implementation of some systems where only the change detection feature is relevant and not the kind of object (resource or component). ## Solution Implement `From<ResMut<T>>` and `From<NonSendMut<T>>` for `Mut`. Since the 3 structs are similar, and only differ by their system param role, the conversion is trivial. --- ## Changelog Added - `From<ResMut>` and `From<NonSendMut>` for `Mut<T>`.
Build failed (retrying...): |
# Objective Enable treating components and resources equally, which can simplify the implementation of some systems where only the change detection feature is relevant and not the kind of object (resource or component). ## Solution Implement `From<ResMut<T>>` and `From<NonSendMut<T>>` for `Mut`. Since the 3 structs are similar, and only differ by their system param role, the conversion is trivial. --- ## Changelog Added - `From<ResMut>` and `From<NonSendMut>` for `Mut<T>`.
Pull request successfully merged into main. Build succeeded: |
ResMut
and NonSendMut
to Mut
ResMut
and NonSendMut
to Mut
@@ -206,6 +217,17 @@ change_detection_impl!(NonSendMut<'a, T>, T,); | |||
impl_into_inner!(NonSendMut<'a, T>, T,); | |||
impl_debug!(NonSendMut<'a, T>,); | |||
|
|||
impl<'a, T: Resource> From<NonSendMut<'a, T>> for Mut<'a, T> { |
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.
This is wrong, should have been:
impl<'a, T: Resource> From<NonSendMut<'a, T>> for Mut<'a, T> { | |
impl<'a, T: 'static> From<NonSendMut<'a, T>> for Mut<'a, T> { |
FYI @alice-i-cecile , @maniwani
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.
Logged as #5456
# Objective Enable treating components and resources equally, which can simplify the implementation of some systems where only the change detection feature is relevant and not the kind of object (resource or component). ## Solution Implement `From<ResMut<T>>` and `From<NonSendMut<T>>` for `Mut`. Since the 3 structs are similar, and only differ by their system param role, the conversion is trivial. --- ## Changelog Added - `From<ResMut>` and `From<NonSendMut>` for `Mut<T>`.
# Objective Enable treating components and resources equally, which can simplify the implementation of some systems where only the change detection feature is relevant and not the kind of object (resource or component). ## Solution Implement `From<ResMut<T>>` and `From<NonSendMut<T>>` for `Mut`. Since the 3 structs are similar, and only differ by their system param role, the conversion is trivial. --- ## Changelog Added - `From<ResMut>` and `From<NonSendMut>` for `Mut<T>`.
# Objective Enable treating components and resources equally, which can simplify the implementation of some systems where only the change detection feature is relevant and not the kind of object (resource or component). ## Solution Implement `From<ResMut<T>>` and `From<NonSendMut<T>>` for `Mut`. Since the 3 structs are similar, and only differ by their system param role, the conversion is trivial. --- ## Changelog Added - `From<ResMut>` and `From<NonSendMut>` for `Mut<T>`.
Objective
Enable treating components and resources equally, which can
simplify the implementation of some systems where only the change
detection feature is relevant and not the kind of object (resource or
component).
Solution
Implement
From<ResMut<T>>
andFrom<NonSendMut<T>>
forMut
. Since the 3 structs are similar, and only differ by their systemparam role, the conversion is trivial.
Changelog
Added -
From<ResMut>
andFrom<NonSendMut>
forMut<T>
.