1#![feature(type_alias_impl_trait, impl_trait_in_assoc_type)]
2
3use nuit::{Text, VStack, View, Bind, Button, State};
4
5#[derive(Bind, Default)]
6struct CounterView {
7 count: State<i32>,
8}
9
10impl View for CounterView {
11 type Body = impl View;
12
13 fn body(&self) -> Self::Body {
14 let count = self.count.clone();
15 VStack::new((
16 Text::new(format!("Count: {}", count.get())),
17 Button::with_text("Increment", move || {
18 count.set(count.get() + 1);
19 })
20 ))
21 }
22}
23
24fn main() {
25 nuit::run_app(CounterView::default());
26}