chore: tweak generic arguments and iterators in rsx
This commit is contained in:
1 parent
e8ae830cf2
commit
e09b6bf813
7 files changed
+93
-66
No files matched your search
+1
-1
@@ -16,7 +16,7 @@ fn app(cx: Scope) -> Element {
|
||||
oninput: move |e| script.set(e.value.clone()),
|
||||
}
|
||||
button {
|
||||
onclick: move |_| eval(script),
|
||||
onclick: move |_| eval(script.to_string()),
|
||||
"Execute"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ fn app(cx: Scope) -> Element {
|
||||
td { class:"col-md-1" }
|
||||
td { class:"col-md-1", "{item.key}" }
|
||||
td { class:"col-md-1", onclick: move |_| selected.set(Some(id)),
|
||||
a { class: "lbl", item.labels }
|
||||
a { class: "lbl", "{item.labels[0]}{item.labels[1]}{item.labels[2]}" }
|
||||
}
|
||||
td { class: "col-md-1",
|
||||
a { class: "remove", onclick: move |_| { items.write().remove(id); },
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
dioxus_desktop::launch(app);
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
generic_child::<i32>{}
|
||||
})
|
||||
}
|
||||
|
||||
fn generic_child<T>(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {}
|
||||
})
|
||||
}
|
||||
@@ -183,7 +183,7 @@ fn app(cx: Scope) -> Element {
|
||||
|
||||
// Components can be generic too
|
||||
// This component takes i32 type to give you typed input
|
||||
TypedInput::<TypedInputProps<i32>> {}
|
||||
TypedInput::<i32> {}
|
||||
|
||||
// Type inference can be used too
|
||||
TypedInput { initial: 10.0 }
|
||||
|
||||
@@ -8,11 +8,12 @@ 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
|
||||
// Collect into an intermediate collection if necessary, and call into_iter
|
||||
["a", "b", "c"]
|
||||
.into_iter()
|
||||
.map(|f| rsx! { "{f}" })
|
||||
.collect::<Vec<_>>(),
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter(),
|
||||
// Use optionals
|
||||
Some(rsx! { "Some" }),
|
||||
))
|
||||
|
||||
Reference in new issue
Block a user