-
-
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
Make run_if_inner
public and rename to run_if_dyn
#9576
Conversation
I would recommend a rename as well while we're at it. Perhaps |
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.
Helpful motivation in the PR description, thanks :)
I'd prefer a more descriptive name and doc strings for this newly public type, but won't block on it. run_if_dyn
gets my vote.
@alice-i-cecile I'm not good at commenting things, so I'm not sure about docs. Could you help me, please? :) |
Does it make sense to also make the |
Sure, I think the same logic applies for that. I'll leave a suggestion for docs :) |
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
…nto pub_run_if_inner
/// Adds a new boxed system set to the systems. | ||
pub fn in_set_dyn(&mut self, set: BoxedSystemSet) { |
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.
Note that this change will be unnecessary if #7762 is merged.
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.
Should I revert that change?
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.
Nah, that PR isn't guaranteed to get merged. Just thought I'd mention that this function might get removed later.
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.
Oh, okay
Co-authored-by: Joseph <21144246+JoJoJet@users.noreply.github.com>
Can you update your PR description to match the changes? |
@alice-i-cecile Updated the description |
run_if_inner
publicrun_if_inner
public and rename to run_if_dyn
Objective
Sometimes you want to create a plugin with a custom run condition. In a function, you take the
Condition
trait and then make aBoxedCondition
from it to store it. And then you want to add that condition to a system, but you can't, because there is only therun_if
function available which takesimpl Condition<M>
instead ofBoxedCondition
. So you have to create a wrapper type for theBoxedCondition
and implement theSystem
andReadOnlySystem
traits for the wrapper (Like it's done in the picture below). It's very inconvenient and boilerplate. But there is an easy solution for that: make therun_if_inner
system that takes aBoxedCondition
public. Also, it makes sense to makein_set_inner
function public as well with the same motivation.A chunk of the source code of the
bevy-inspector-egui
crate.Solution
Make
run_if_inner
function public.Rename
run_if_inner
torun_if_dyn
.Make
in_set_inner
function public.Rename
in_set_inner
toin_set_dyn
.Changelog
Changed visibility of
run_if_inner
frompub(crate)
topub
.Renamed
run_if_inner
torun_if_dyn
.Changed visibility of
in_set_inner
frompub(crate)
topub
.Renamed
in_set_inner
toin_set_dyn
.Migration Guide