Instead of:
let element: Element<'_, Message> = Column::new()
.style(column_style)
.push(
Button::new(button_state, Text::new("abc"))
.style(button_style)
.on_press(on_press)
)
.push(Text::new("output"))
.into()
I would prefer:
let element: Element<'_, Message> = iced::rsx! {
<Column style={column_style}>
<Button on_press={on_press} style={button_style}>
<Text>abc</Text>
</Button>
<Text>output</Text>
</Column>
}.into()
It's important to note that these macros could be built on top of iced by anyone, as they are just rewriting calls to the public API.
Personally, I am not convinced. I shared some of my thoughts on this in #61. In the end, I believe the improvement here is very subjective and I'd like to see some more discussion and exploration.
You can refer to yew or typed-html in this regard, but the combination of native rust syntax and XML-like syntax is not perfect.
And I think the main problem is that the IDE does not support such macros enough, it cannot detect the type, rename and refactor.
Maybe the rust team can solve these problems in the future by standardizing an rsx format 馃榾.
Most helpful comment
It's important to note that these macros could be built on top of
icedby anyone, as they are just rewriting calls to the public API.Personally, I am not convinced. I shared some of my thoughts on this in #61. In the end, I believe the improvement here is very subjective and I'd like to see some more discussion and exploration.