-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add Self: Sized
bounds to Bundle
trait methods
#14879
base: main
Are you sure you want to change the base?
Conversation
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.
Neat! Can you please add a doc test to Bundle
to verify that Box<dyn Bundle>
works, and can be inserted and removed correctly?
I've linked the issue I made several years ago for this problem in your PR description. I'm going to put this in 0.15 instead of a 0.14 point release just in case we've missed some terrible edge case on the breaking changes. |
To be clear, this isn't a drop-in dynamic bundle solution, however, reading through that issue, it looks like it wasn't far from being pushed through. I can turn this into a full-on dynamic bundle PR, I think my preferred solution would be to add a couple object-safe helper methods on |
I'd prefer to turn this into a full-on dynamic bundle PR IMO :) This is very unintrusive, and there would be a lot of value in a solution there. Probably spin up an ECS folder example? |
Objective
Fixes #3227.
I'll admit upfront this might be some silly shenanigans.
This came about based on some Rust-fu I was trying to do to enable generic dynamic bundle insertion/removal. Consider the following snippet:
This doesn't compile, and from my perspective, understandably: a
Bundle
that doesn't know its type can't get into the world. A workaround I came up with is this:A component can impl this trait (or derive it) and suddenly you have a working system! Only problem is Rust thinks it's not possible since some of
Bundle
's methods (erroneously) assumeSelf: ?Sized
.Solution
Add
where Self: Sized
to the rest ofBundle
's (andDynamicBundle
's) trait methodsBreaking change?
Technically, I think?
I'm not exactly sure what kind of code you'd have to write to run into this breaking change, but this change expands what you can do with bundles, not the other way around. I'll try and find some weird bit of code that breaks with this, but I don't think it needs a migration guide section, and honestly, I don't think it would be bad to shove it into 0.14.2, however I understand that still breaks the letter of the law and is a solid argument against doing so.