2022-09-12 22:49:04 -07:00
|
|
|
use dioxus::prelude::*;
|
|
|
|
|
|
|
|
fn main() {
|
2024-01-16 11:45:02 -06:00
|
|
|
launch_desktop(app);
|
2022-09-12 22:49:04 -07:00
|
|
|
}
|
|
|
|
|
2024-01-13 20:51:37 -08:00
|
|
|
fn app() -> Element {
|
2024-01-16 13:18:46 -06:00
|
|
|
rsx!(
|
2022-11-16 22:20:41 -08:00
|
|
|
div {
|
2022-11-15 23:22:41 -08:00
|
|
|
// Use Map directly to lazily pull elements
|
2024-01-16 13:18:46 -06:00
|
|
|
{(0..10).map(|f| rsx! { "{f}" })},
|
2022-11-15 23:31:23 -08:00
|
|
|
|
2022-11-15 23:22:41 -08:00
|
|
|
// Collect into an intermediate collection if necessary, and call into_iter
|
2024-01-10 19:33:34 -08:00
|
|
|
{["a", "b", "c", "d", "e", "f"]
|
2022-11-15 23:22:41 -08:00
|
|
|
.into_iter()
|
2024-01-16 13:18:46 -06:00
|
|
|
.map(|f| rsx! { "{f}" })
|
2022-11-15 23:22:41 -08:00
|
|
|
.collect::<Vec<_>>()
|
2024-01-10 19:33:34 -08:00
|
|
|
.into_iter()},
|
2022-11-15 23:22:41 -08:00
|
|
|
|
|
|
|
// Use optionals
|
2024-01-16 13:18:46 -06:00
|
|
|
{Some(rsx! { "Some" })},
|
2022-11-16 22:10:50 -08:00
|
|
|
|
2022-11-17 22:55:46 -08:00
|
|
|
// use a for loop where the body itself is RSX
|
2022-11-16 22:20:41 -08:00
|
|
|
for name in 0..10 {
|
2022-11-17 22:55:46 -08:00
|
|
|
div {"{name}"}
|
2022-11-16 22:20:41 -08:00
|
|
|
}
|
2022-11-16 22:10:50 -08:00
|
|
|
|
2022-11-16 22:20:41 -08:00
|
|
|
// Or even use an unterminated conditional
|
|
|
|
if true {
|
2024-01-10 19:33:34 -08:00
|
|
|
"hello world!"
|
2022-11-16 22:10:50 -08:00
|
|
|
}
|
2022-11-15 23:22:41 -08:00
|
|
|
}
|
2024-01-13 21:12:21 -08:00
|
|
|
)
|
2022-09-12 22:49:04 -07:00
|
|
|
}
|