-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Merge BuildWorldChildren
and BuildChildren
traits.
#14052
base: main
Are you sure you want to change the base?
Conversation
- Add an associated type to `BuildChildren` which reflects the prior differences between the `BuildChildren` and `BuildWorldChildren` traits. - Add `ChildBuild` trait that is the bounds for `BuildChildren::Builder`, with impls for `ChildBuilder` and `WorldChildBuilder`. - Remove `BuildWorldChildren` trait and replace it with an impl of `BuildChildren` for `EntityWorldMut`.
Lovely, I was hoping we could do this. |
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 like the changes. Thanks!
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.
Great idea, thanks! Just some minor notes.
/// implementations of [`BuildChildren`] as a bound on the [`Builder`](BuildChildren::Builder) | ||
/// associated type. The closure passed to [`BuildChildren::with_children`] accepts an | ||
/// implementation of `ChildBuild` so that children can be spawned via [`ChildBuild::spawn`]. | ||
pub trait ChildBuild { |
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.
Worth thinking about whether we want the user to be able to implement this trait on their own. The current API implies this and makes adding a new method a breaking change.
I'm personally leaning towards sealing the trait.
What do you think @alice-i-cecile?
Note that the same conversation can be had for BuildChildren
.
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.
IMO we don't bother sealing this but we also just don't really care about adding new methods. This isn't long for the world: complexity isn't worth it here.
Objective
The
BuildChildren
andBuildWorldChildren
traits are mostly identical, so I decided to try and merge them. I'm not sure of the history, maybe they were added before GATs existed.Solution
BuildChildren
which reflects the prior differences between theBuildChildren
andBuildWorldChildren
traits.ChildBuild
trait that is the bounds forBuildChildren::Builder
, with impls forChildBuilder
andWorldChildBuilder
.BuildWorldChildren
trait and replace it with an impl ofBuildChildren
forEntityWorldMut
.Testing
I ran several of the examples that use entity hierarchies, mainly UI.
Changelog
n/a
Migration Guide
n/a