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

Add Widget derive macro #130

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

atlanticaccent
Copy link
Contributor

This PR adds a new derive macro for implementing Widget automatically on a struct.

By default the macro assumes the struct has a WidgetPod field named widget_pod and forwards all Widget trait methods to the WidgetPod's implementation. In the case a user chooses not to have a child widget, they need only provide implementations for all the required Widget methods. The user can also choose to name a different field as containing the WidgetPod.

As in the example, this behaviour can be mixed and matched, with the named WidgetPod having some methods forwarded to it, with other method implementations "overridden" in the provided method implementations on the struct.

Open issues:

  • The macro's handling of generics is currently quite fragile, assuming the name of the generic implementing Data is T and the name of the generic implementing Widget is W. It does try to handle any additional bounds on the Data type.

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 this pull request may close these issues.

1 participant