mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-12-22 02:23:05 +00:00
26 lines
465 B
Rust
26 lines
465 B
Rust
use std::fmt::Display;
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
fn main() {
|
|
dioxus_desktop::launch(app);
|
|
}
|
|
|
|
fn app(cx: Scope) -> Element {
|
|
cx.render(rsx! { generic_child {
|
|
data: 0i32
|
|
} })
|
|
}
|
|
|
|
#[derive(PartialEq, Props)]
|
|
struct GenericChildProps<T: Display + PartialEq> {
|
|
data: T,
|
|
}
|
|
|
|
fn generic_child<T: Display + PartialEq>(cx: Scope<GenericChildProps<T>>) -> Element {
|
|
let data = &cx.props.data;
|
|
|
|
cx.render(rsx! { div {
|
|
"{data}"
|
|
} })
|
|
}
|