Support systems that take references as input#15184
Support systems that take references as input#15184alice-i-cecile merged 38 commits intobevyengine:mainfrom
Conversation
|
I'd personally rather |
|
Makes sense, nvm then. |
bushrat011899
left a comment
There was a problem hiding this comment.
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.
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.
I added Deref/DerefMut impls for all SystemInputs 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.
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 <giaco.stevanato@gmail.com>
|
@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
A backport of #18840 to version 0.15.3. I was unsure whether I should also update the versions of all crates. Looking at previous backports this was not done. The code which relies on the old solver behavior was introduced in #15184 which is from version 0.15. So this is the only version which needs a backport. cc @mockersf
Objective
'staticTriggerand that's unsound #14924Solution
SystemInput, that serves as a type function from the'staticform of the input, to its lifetime'd version, similarly toSystemParamorWorldQuery.SystemInput::Param<'_>, which prevents the issue presented in Observers get a'staticTriggerand that's unsound #14924 (i.e.InRef<T>).SystemInput::Inner<'_>(i.e.&T).CombinatorSystemas 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.