Skip to content

Implemented #[bundle(ignore)] and #[bundle(nest)]#5579

Merged
maccesch merged 0 commit intobevyengine:mainfrom
Synphonyte:main
Aug 9, 2022
Merged

Implemented #[bundle(ignore)] and #[bundle(nest)]#5579
maccesch merged 0 commit intobevyengine:mainfrom
Synphonyte:main

Conversation

@maccesch
Copy link
Copy Markdown
Contributor

@maccesch maccesch commented Aug 5, 2022

Objective

Fixes #5559

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.


Migration Guide

In #[derive(Bundle)] structs:

#[bundle] => #[bundle(nest)]

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Aug 5, 2022
@alice-i-cecile
Copy link
Copy Markdown
Member

my implementation requires any field type that is marked to be ignored to implement Default.

I'm fine with this limitation as this feature is overwhelmingly going to be used for PhantomData.

@maxwellodri
Copy link
Copy Markdown
Contributor

maxwellodri commented Aug 5, 2022

From a user perspective, I like this change. I tested the changes with a field with [bundle(ignore)] that doesn't implement Default and the error message is clear that you need to impl Default FWIW.

@Nilirad Nilirad added the M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Aug 5, 2022
@Nilirad
Copy link
Copy Markdown
Contributor

Nilirad commented Aug 5, 2022

Breaking change since #[bundle] becomes #[bundle(nest)]

/// a: A,
/// z: Z,
/// #[bundle(ignore)]
/// other: Other,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should use a PhantomData type + a bundle generic here, as it much more clearly motivates this feature.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the new PR I added the PhantomData but left this because I figured it demonstrates the Default trait requirement. Let me know if you want me to remove it.


/// An enum that describes possible types of value in flexbox layout options
///
/// There are numeric traits implemented for this enum so you can multiply, divide, add, and subtract
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are unrelated; please remove them :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry! that must have slipped in somehow!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to a bug in GitHub I had to create another PR for this: #5628

@maccesch maccesch merged commit 0ffb544 into bevyengine:main Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to ignore field of bundle

4 participants