-
Notifications
You must be signed in to change notification settings - Fork 1
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
Reduce boilerplate code with macros #61
Conversation
Currently, property handles have to be exposed to the user during building. However, I may have an idea to solve this too 🤔 |
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.
That will save a lot of typing 😬
PR description updated |
When rust-lang/rust#29635 was stabilized, we wouldn't even need the proc macro for this, but could simply provide a generic wrapper struct |
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.
Awesome!
This suggests splitting
xxx_handle_mut()
functions into separate traits, and adding functionsxxx_handle()
to these which return an immutable references. A proc macro can then be used to auto-implement these traits, including adding a field holding the handle to the struct.Ultimately, this should also unify the code by wrapping EventHandles in Events, and adding an APIHandlerHandle. Solely the Action would remain different (would they?).
Examples
is equivalent to
and is equivalent to previously doing