1
0

generic_component.rs 440 B

123456789101112131415161718192021222324
  1. use std::fmt::Display;
  2. use dioxus::prelude::*;
  3. fn main() {
  4. dioxus_desktop::launch(app);
  5. }
  6. fn app() -> Element {
  7. render! {
  8. generic_child { data: 0 }
  9. }
  10. }
  11. #[derive(PartialEq, Props, Clone)]
  12. struct GenericChildProps<T: Display + PartialEq + Clone + 'static> {
  13. data: T,
  14. }
  15. fn generic_child<T: Display + PartialEq + Clone>(props: GenericChildProps<T>) -> Element {
  16. render! {
  17. div { "{props.data}" }
  18. }
  19. }