feat: implement type magic to allow strings, format args, and other types directly in rsx (#550)

* feat: implement type magic

* chore: undo example

* fix: let tests pass

* chore: add generic to allow any nesting of iterators

* Chore: remove comments

* chore: update rsx usage

* chore: use cleaner version of generic IntoVnode

* chore: don't derive default for lfietimed thing

* chore: remove latent comment

* fix: accept a third parameter
This commit is contained in:
Jon Kelley authored and GitHub committed 2022-09-12 22:49:04 -07:00
1 parent 38e8745db9
commit 67dc6e6017
7 files changed
+80 -100

No files matched your search

+2 -2
View File
@@ -203,8 +203,8 @@ fn app(cx: Scope) -> Element {
self::lowercase_helper {}
// helper functions
// Single values must be wrapped in braces or `Some` to satisfy `IntoIterator`
[helper(&cx, "hello world!")]
// Anything that implements IntoVnode can be dropped directly into Rsx
helper(&cx, "hello world!")
}
})
}
+19
View File
@@ -0,0 +1,19 @@
use dioxus::prelude::*;
fn main() {
dioxus_desktop::launch(app);
}
fn app(cx: Scope) -> Element {
cx.render(rsx!(
// Use Map directly to lazily pull elements
(0..10).map(|f| rsx! { "{f}" }),
// Collect into an intermediate collection if necessary
["a", "b", "c"]
.into_iter()
.map(|f| rsx! { "{f}" })
.collect::<Vec<_>>(),
// Use optionals
Some(rsx! { "Some" }),
))
}