ansiq-macros
ansiq-macros mainly provides view!.
Its job is not to invent a second runtime. Its job is to connect declarative tree syntax to the existing widget and Element model.
What view! solves
With builders only, a tree often looks like this:
Box::column()
.child(Text::new("Header"))
.child(List::new(items))
.child(StatusBar::new("ready"))view! makes the same structure read like a declarative tree:
view! {
<Box direction={Direction::Column}>
<Text value="Header" />
<List items={items} />
<StatusBar text="ready" />
</Box>
}This does not change the runtime model. It changes how you describe the UI tree.
How it relates to builders
The important rule is:
- builders and
view!are two entry points - they still target the same
Element/ props model underneath
That means:
- you can mix them
- you do not need to learn a second runtime mental model
- a builder-based example does not need to be rewritten just to use the macro
When view! is usually the better fit
Good fit:
- clearly nested component trees
- documentation examples
- shells composed from multiple panes
Not always better:
- very small one-widget examples
- code with lots of loops or conditional builder logic
Recommended next reading
- Components and view!
- ansiq-widgets
- rustdoc for exact
view!syntax support
Last updated on