-
Notifications
You must be signed in to change notification settings - Fork 169
Fix macros to allow an arbitrary number of properties in Xilem views #1161
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
Conversation
|
Philip suggested using type composition instead, which we might adopt. This is more of a short-term fix. See discussion on zulip: #xilem > Refactor property system to use a composition property view. |
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.
Looks good, should at least unblock more than 12 properties.
I don't think though the trait PropertyTuple is necessary anymore though is it?
Could just be normal methods on all the Props types.
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.
This looks good - I'd like to see better handling of the new public API which this creates.
I think that having PropertyTuple still is reasonable - it ensures that the new methods have at least some basic docs and consistent semantics. It does need have its docs changed, at least, in this PR, and probably also to be renamed.
| type $Props = ($(Option<$Type>,)+); | ||
|
|
||
| #[expect(missing_docs)] | ||
| pub struct $Props($(Option<$Type>,)+); |
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.
Why is this pub? I don't think this type is going to be part of the public API of any widget, nor have any stability guarantees.
I think it should at least have some basic docs if you're going to make it so.
Or it should be expect(unreachable_pub), if it's for the associated type on Style
(it probably should have some basic docs anyway, even just mentioning that you should call rebuild_properties in rebuild and build_properties in build, and initialise it with Default)
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.
I think this comment still stands - I'd like to understand why this type is pub before approving. I see that you've added the requested docs - thanks!
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.
Oh, right, forgot to answer. Sorry.
It needs to be pub because it's used as an associated type for the various implementations of the Style trait, and you're not allowed to do that with a private type. We could do a pub-in-private trick or something similar, but I think just making it a pub item works for now.
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.
Seems reasonable enough. I have a small follow-up I'd like to do
Fixes the issues encountered in #1099.