-
-
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
Change plugin to consume self #4212
Conversation
9c796f1
to
88b31dc
Compare
88b31dc
to
c8b26c5
Compare
So, this is interesting. The box is pretty unfortunate; I'm not sure I love it in a public beginner oriented API like this. That said, plugin building definitely feels like it should take ownership rather than just reference, allowing users to move in unclonable objects. |
I think plugins should preferrably be configured using resources and be ZST's themself. This would play nicer with the future editor I think. |
This also plays nicer with some of my thoughts around structured plugins, by allowing us to avoid accounting for custom configuration parameters. |
The box is a non-starter imo, not only it is not idiomatic, but also unnecessary and would make the common case more expensive (force one to make an allocation) and more confusing. The idiomatic thing to do and the common pattern for builders is to take I don't understand why not just box the schedule in your example / or have an option. |
Furthermore, this change would break all libraries out there -- I appreciate bevy needs to move fast and break things, but FWIW, the use case presented by the OP does not warrant the breakage as it's very easy to workaround |
@hymm I think these arguments are compelling: this was a useful experiment, but I think ultimately a non-starter. Shall we close this out? |
That prevents turning |
And we can't make |
I don't know of any plugin storing internal unsized configuration. Creating such a plugin requires unsafe code. I was talking about not passing self by value as being required to allow |
Yeah, I'll close this out. |
Worth noting that there is previous discussion of this, i.e. in #1045 (and https://discord.com/channels/691052431525675048/692572690833473578/748241380010098749). I was surprised that #1045 wasn't linked in the PR description, unless I'm missing it I don't think there's anything hugely important in the discord link. Only cart's comment:
|
Yes indeed, good point 👍 |
Something else worth calling out: consuming self would mean that the Plugin's init isn't a repeatable process, which might come in handy for things like editors, hot reloading, etc. I think we should be moving in the direction of "plugins are completely stateless by default and configured with an instance of a specific type (ideally with a default impl)" |
Objective
Schedule
.Solution
build
. It needs to be boxed because internallyApp
stores the plugin as adyn Plugin
and this is not sized so cannot be moved. So changingbuild
to use aBox<Self>
allows it to be moved into the function.Question
Box<Self>
in a common public API?