Make the function bounds for map less restrictive

This commit is contained in:
Evan Almloff committed 2023-12-23 13:43:27 -06:00
1 parent bfacf94db4
commit a2fadc8d11
3 files changed
+30 -2

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
use dioxus::prelude::*;
use dioxus_signals::*;
fn main() {
dioxus_desktop::launch(App);
}
#[component]
fn App(cx: Scope) -> Element {
let signal = use_signal(cx, || vec![String::from("Hello"), String::from("World")]);
render! {
button {
onclick: move |_| {
signal.write().push(String::from("Hello"));
},
"Add one"
}
for i in 0..signal().len() {
Child { signal: signal.map(move |v| v.get(i).unwrap()) }
}
}
}
#[component]
fn Child(cx: Scope, signal: SignalMap<String>) -> Element {
render! {"{signal:?}"}
}