-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Support systems that take references as input #15184
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
Conversation
I'd personally rather |
Makes sense, nvm then. |
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.
I really like this change and I'm excited to see what we can do once this is merged. Excellent work handling the early DX regressions in type inference.
impl<'w, E, B: Bundle> Deref for Trigger<'w, E, B> { | ||
type Target = E; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
self.event | ||
} | ||
} | ||
|
||
impl<'w, E, B: Bundle> DerefMut for Trigger<'w, E, B> { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
self.event | ||
} | ||
} |
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.
Was there a particular reason this was added in this PR? I don't disagree with the implementation, but it feels tangential to the goal here.
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.
I added Deref
/DerefMut
impls for all SystemInput
s for future generic usage of abstracting over mutable or readonly access to a type in the input: where I: SystemInput + DerefMut<Target = String>
, for example. Since Trigger
is now a SystemInput
, I added it for equality. If it's a controversial change I'm fine with removing it, but thought I might as well since we're mucking around with observers here.
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.
No that seems perfectly reasonable, thanks for clarifying! Just wanted to get the reasoning written down in-case anyone else had the same thought.
Do we need SystemInput::unwrap method? It seems only wrap is needed. |
It's not currently used anywhere but might prove useful in the future. |
I asked because:
Okay. |
My guess is that |
Co-authored-by: Giacomo Stevanato <[email protected]>
@alice-i-cecile Should be good to go as long as this addition is correct: c08d853 (from #15276) |
Yep, that validation is correct. Thanks! |
Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to bevyengine/bevy-website#1695 if you'd like to help out. |
…State::build_system_with_input (bevyengine#17034) # Objective - Made certain methods public for advanced use cases. Methods that returns mutable references are marked as unsafe due to the possibility of violating internal lifetime constraint assumptions. - Fixes an issue introduced by bevyengine#15184
…State::build_system_with_input (bevyengine#17034) # Objective - Made certain methods public for advanced use cases. Methods that returns mutable references are marked as unsafe due to the possibility of violating internal lifetime constraint assumptions. - Fixes an issue introduced by bevyengine#15184
Objective
'static
Trigger
and that's unsound #14924Solution
SystemInput
, that serves as a type function from the'static
form of the input, to its lifetime'd version, similarly toSystemParam
orWorldQuery
.SystemInput::Param<'_>
, which prevents the issue presented in Observers get a'static
Trigger
and that's unsound #14924 (i.e.InRef<T>
).SystemInput::Inner<'_>
(i.e.&T
).CombinatorSystem
as it was previously.Trigger<'static, E, B>
transmute in observer runner code.Testing
Showcase
Migration Guide
SystemId<I, O>
toSystemId<In<I>, O>
System<In = T>
toSystem<In = In<T>>
IntoSystem<I, O, M>
toIntoSystem<In<I>, O, M>
Condition<M, T>
toCondition<M, In<T>>
In<Trigger<E, B>>
is no longer a valid input parameter type. UseTrigger<E, B>
directly, instead.