bevy
bevy copied to clipboard
Compiler Error on `#[derive(Bundle)]` for Generic Bundles in 0.16
Bevy version
Bevy 0.16
What you did
This is a follow up to this discussion.
The following code no longer compiles as of Bevy 0.16:
use bevy::prelude::*;
#[derive(Bundle)]
struct Foo<T: Bundle>(T);
error[E0277]: the trait bound `T: BundleFromComponents` is not satisfied
I understand this requires BundleFromComponent trait bound to work because of the new changes to Bundles:
use bevy::prelude::*;
use bevy::ecs::bundle::BundleFromComponents;
#[derive(Bundle)]
struct Foo<T: Bundle + BundleFromComponents>(T);
However, as discussed, this feels like a regression since BundleFromComponents is mostly an implementation detail (to me, at least).
Additional information
Some solutions that come to my mind:
- We could have
BundlerequireBundleFromComponentsas a trait bound. But this makes me wonder why this trait was split out to begin with. - We could introduce a new
CompleteBundletrait (naming is hard) which does requireBundleFromComponentand changederive(Bundle)toderive(CompleteBundle)instead.
#3227 is related, as both involve refactors to the Bundle family of traits.