-
-
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
[Merged by Bors] - implemented #[bundle(ignore)] #6123
Conversation
FYI Github has a built-in "Draft mode" for WIP PRs :) |
@alice-i-cecile Ok all fixed |
Co-authored-by: Nathan Ward <[email protected]>
Co-authored-by: Nathan Ward <[email protected]>
Co-authored-by: Afonso Lage <[email protected]>
Co-authored-by: Afonso Lage <[email protected]>
@alice-i-cecile I was thinking about this, and I'm not sure about what I'm about to propose 😄 Instead of having a The downside would be that if you had a custom type called |
Don't actually think this is possible, at least at the macro level using the name type GhostData<T> = PhantomData<T>;
#[derive(Bundle)]
pub struct MyBundle<T> {
ghost: GhostData<T>,
// ..
} And it's also impossible to do it via any sort of type matching e.g. if TypeId::of<BundleField>() == TypeId::of<PhantomData<?>> {} Since Granted I'm sure there's probably some hackery you could do with a trait, however, IMO |
Oh, and one last thing, could we add a test for this? |
@NathanSWard When making my suggestion I actually had these limitations in mind. I implemented a derive macro for Dioxus where we decided to make all Having said that it is true that the aforementioned I still think the ergonomics would be worth it. Maybe instead we could have a #[bundle(include)]
data: PhantomData<...>, that counteracts the default exclusion for the case that somebody really did name a component "PhantomData" (lol) and leave the So in conclusion:
|
Fwiw, I'm definitely not a big fan of I'm just generally against any sort of "stringly" typed imementation which is what you seem to be proposing. |
This also extends to other marker types, e.g. |
Yep, this is my feeling. I also like how much more explicit the ignore solution is. Deviations from the expected behavior should be called out. |
Ok got it. Thanks for considering 😄 |
@NathanSWard test added ✔️ |
I agree that we should have |
IMO this is too implicit. It leads to weird behavior where you can e.g. insert a |
|
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 macro code, good tests, useful little feature.
bors r+
# Objective Fixes #5559 Replaces #5628 ## Solution Because the generated method from_components() creates an instance of Self my implementation requires any field type that is marked to be ignored to implement Default. --- ## Changelog Added the possibility to ignore fields in a bundle with `#[bundle(ignore)]`. Typically used when `PhantomData` needs to be added to a `Bundle`.
Build failed (retrying...): |
# Objective Fixes #5559 Replaces #5628 ## Solution Because the generated method from_components() creates an instance of Self my implementation requires any field type that is marked to be ignored to implement Default. --- ## Changelog Added the possibility to ignore fields in a bundle with `#[bundle(ignore)]`. Typically used when `PhantomData` needs to be added to a `Bundle`.
# Objective Fixes bevyengine#5559 Replaces bevyengine#5628 ## Solution Because the generated method from_components() creates an instance of Self my implementation requires any field type that is marked to be ignored to implement Default. --- ## Changelog Added the possibility to ignore fields in a bundle with `#[bundle(ignore)]`. Typically used when `PhantomData` needs to be added to a `Bundle`.
# Objective Fixes bevyengine#5559 Replaces bevyengine#5628 ## Solution Because the generated method from_components() creates an instance of Self my implementation requires any field type that is marked to be ignored to implement Default. --- ## Changelog Added the possibility to ignore fields in a bundle with `#[bundle(ignore)]`. Typically used when `PhantomData` needs to be added to a `Bundle`.
# Objective Fixes bevyengine#5559 Replaces bevyengine#5628 ## Solution Because the generated method from_components() creates an instance of Self my implementation requires any field type that is marked to be ignored to implement Default. --- ## Changelog Added the possibility to ignore fields in a bundle with `#[bundle(ignore)]`. Typically used when `PhantomData` needs to be added to a `Bundle`.
Objective
Fixes #5559
Replaces #5628
Solution
Because the generated method from_components() creates an instance of Self my implementation requires any field type that is marked to be ignored to implement Default.
Changelog
Added the possibility to ignore fields in a bundle with
#[bundle(ignore)]
. Typically used whenPhantomData
needs to be added to aBundle
.