simple_list.rs 860 B

12345678910111213141516171819202122232425262728293031323334
  1. use dioxus::prelude::*;
  2. fn main() {
  3. dioxus_desktop::launch(app);
  4. }
  5. fn app(cx: Scope) -> Element {
  6. cx.render(rsx!(
  7. div {
  8. // Use Map directly to lazily pull elements
  9. (0..10).map(|f| rsx! { "{f}" }),
  10. // Collect into an intermediate collection if necessary, and call into_iter
  11. ["a", "b", "c", "d", "e", "f"]
  12. .into_iter()
  13. .map(|f| rsx! { "{f}" })
  14. .collect::<Vec<_>>()
  15. .into_iter(),
  16. // Use optionals
  17. Some(rsx! { "Some" }),
  18. // use a for loop where the body itself is RSX
  19. for name in 0..10 {
  20. div {"{name}"}
  21. }
  22. // Or even use an unterminated conditional
  23. if true {
  24. rsx!{ "hello world!" }
  25. }
  26. }
  27. ))
  28. }