-
Notifications
You must be signed in to change notification settings - Fork 79
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
With attribute #128
With attribute #128
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.
Thanks for the contribution. This is a great idea, and in hindsight it seems so obvious. Def wanna get this in.
Please add some documentation w/ an example to |
Ready for another review! |
Checked with |
okay, third times the charm 😅 |
Thanks @Trouv for reviewing!! |
Summary
Adds a new attribute to the
LdtkEntity
derive macro namedwith
. It allows for bundles to implement custom initializers using a method. This macro takes in a scoped function with signature(e: EntityInstance) -> T
where T is the field type.Example
Longer Example
Issue
The same functionality can be done using
from_entity_instance
by filtering theidentifier
to the correct type. However, this could cause function bloat when many entities with different identifiers implement the same bundle. You can have cleaner and safer code separation with thiswith(function)
attribute.ToDo