2023-04-23 16:54:40 +00:00
|
|
|
use std::fmt::Display;
|
|
|
|
|
2022-11-16 04:58:56 +00:00
|
|
|
use dioxus::prelude::*;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
dioxus_desktop::launch(app);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn app(cx: Scope) -> Element {
|
2023-04-23 16:54:40 +00:00
|
|
|
cx.render(rsx! { generic_child {
|
|
|
|
data: 0i32
|
|
|
|
} })
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Props)]
|
|
|
|
struct GenericChildProps<T: Display + PartialEq> {
|
|
|
|
data: T,
|
2022-11-16 04:58:56 +00:00
|
|
|
}
|
|
|
|
|
2023-04-23 16:54:40 +00:00
|
|
|
fn generic_child<T: Display + PartialEq>(cx: Scope<GenericChildProps<T>>) -> Element {
|
|
|
|
let data = &cx.props.data;
|
|
|
|
|
|
|
|
cx.render(rsx! { div {
|
|
|
|
"{data}"
|
|
|
|
} })
|
2022-11-16 04:58:56 +00:00
|
|
|
}
|