Skip to content
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

#[ldtk_int_cell], #[from_entity_instance] etc. should not require a Default impl #305

Closed
neocturne opened this issue Mar 2, 2024 · 0 comments · Fixed by #306
Closed

Comments

@neocturne
Copy link
Contributor

Since #222, Default must be implemented to derive LdtkEntity, LdtkIntCell etc.

This does not interact well with #[from_entity_instance] and similar attributes, as I was using the attributes on fields where there is no reasonable way to implement Default (like a struct containing a Box<dyn ...>). With the change, I either have to:

  • impl Default for my field to I can derive it for my LdtkEntity type, or
  • manually impl Default for my LdtkEntity type, still requiring me to create a field instance out of thin air

While I could make up some value just to be able to implement Default, doing so would feel like a misuse of the Default trait.

neocturne added a commit to neocturne/bevy_ecs_ldtk that referenced this issue Mar 2, 2024
…acros

Add an attribute that initializes fields using individual field Default
implementations, allowing to use the derive macros again without
requiring the whole struct to implement Default (when some fields should
be default-initialized and others use initialization attributes
like #[from_entity_instance]).

Fixes Trouv#305
Trouv pushed a commit to neocturne/bevy_ecs_ldtk that referenced this issue Jul 9, 2024
…acros

Add an attribute that initializes fields using individual field Default
implementations, allowing to use the derive macros again without
requiring the whole struct to implement Default (when some fields should
be default-initialized and others use initialization attributes
like #[from_entity_instance]).

Fixes Trouv#305
@Trouv Trouv closed this as completed in #306 Jul 9, 2024
@Trouv Trouv closed this as completed in 416a46e Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant