use std::fmt::Display; use dioxus::prelude::*; // This test just checks that props compile with generics // It will not actually run any code #[test] #[allow(unused)] #[allow(non_snake_case)] fn generic_props_compile() { fn app() -> Element { rsx! { TakesClone { value: "hello world" } TakesCloneManual { value: "hello world" } TakesCloneManualWhere { value: "hello world" } GenericFnWhereClause { value: "hello world" } } } #[component] fn TakesClone(value: T) -> Element { rsx! {} } #[component] fn TakesCloneArc(value: std::sync::Arc) -> Element { rsx! {} } struct MyBox(std::marker::PhantomData); impl Clone for MyBox { fn clone(&self) -> Self { MyBox(std::marker::PhantomData) } } impl PartialEq for MyBox { fn eq(&self, _: &Self) -> bool { true } } #[component] #[allow(clippy::multiple_bound_locations)] fn TakesCloneMyBox(value: MyBox) -> Element where T: Display, { rsx! {} } #[derive(Props, Clone, PartialEq)] struct TakesCloneManualProps { value: T, } fn TakesCloneManual(props: TakesCloneManualProps) -> Element { rsx! {} } #[derive(Props, Clone, PartialEq)] struct TakesCloneManualWhereProps where T: Clone + PartialEq + 'static, { value: T, } fn TakesCloneManualWhere( props: TakesCloneManualWhereProps, ) -> Element { rsx! {} } #[derive(Props, Clone, PartialEq)] struct TakesCloneManualWhereWithOwnerProps where T: Clone + PartialEq + 'static, { value: EventHandler, } fn TakesCloneManualWhereWithOwner( props: TakesCloneManualWhereWithOwnerProps, ) -> Element { rsx! {} } #[component] fn GenericFnWhereClause(value: T) -> Element where T: Clone + PartialEq + Display + 'static, { rsx! { p { "{value}" } } } }