Skip to content

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