-
Notifications
You must be signed in to change notification settings - Fork 9
Eliminate struct enum variants #63
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
Eliminate struct enum variants #63
Conversation
nicoburns
commented
May 28, 2025
- Fixes Enum Struct Variants are Hard To Use #59 by creating dedicated structs for button press and scroll events
|
Does this improve or simplify your usage in Blitz as well? Can you give a brief example so that we have a history of the motivation? |
|
I don't have
(2) is the more significant. However, an example of (1) with a different enum struct-variant from Dioxus: With struct-variant: fn map_template_attr(attr: &TemplateAttribute) -> Option<Attribute> {
let TemplateAttribute::Static {
name,
value,
namespace,
} = attr
else {
return None;
};
let name = qual_name(name, *namespace);
let value = value.to_string();
Some(Attribute { name, value })
}With actual struct inside tuple-variant: fn map_template_attr(attr: &TemplateAttribute) -> Option<Attribute> {
let TemplateAttribute::Static(attr) else {
return None;
};
let name = qual_name(attr.name, *attr.namespace);
let value = attr.value.to_string();
Some(Attribute { name, value })
} |
a6fd121 to
0cc7663
Compare
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 overall, setting aside the one nitpick and getting it rebased with the mutating tap counter change, I'm happy with it. :+ )
I personally don't prefer the separate structs, but if it is an easier API for others (and it seems widely preferred) then I'm fine with it.
Signed-off-by: Nico Burns <[email protected]>
0cc7663 to
9c3dd54
Compare
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.
LGTM apart from a copy/paste thing in a doc comment.
Signed-off-by: Nico Burns <[email protected]>
9c3dd54 to
65f2bd3
Compare