mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-22 12:13:04 +00:00
Fix deriving props with a where clause and an owner (#2674)
This commit is contained in:
parent
aa4a395884
commit
40f936d56a
2 changed files with 66 additions and 1 deletions
|
@ -1397,12 +1397,13 @@ Finally, call `.build()` to create the instance of `{name}`.
|
|||
let original_name = &self.name;
|
||||
let vis = &self.vis;
|
||||
let generics_with_bounds = &self.generics;
|
||||
let where_clause = &self.generics.where_clause;
|
||||
|
||||
quote! {
|
||||
#[doc(hidden)]
|
||||
#[allow(dead_code, non_camel_case_types, missing_docs)]
|
||||
#[derive(Clone)]
|
||||
#vis struct #name #generics_with_bounds {
|
||||
#vis struct #name #generics_with_bounds #where_clause {
|
||||
inner: #original_name #ty_generics,
|
||||
owner: Owner,
|
||||
}
|
||||
|
|
64
packages/core-macro/tests/generics.rs
Normal file
64
packages/core-macro/tests/generics.rs
Normal file
|
@ -0,0 +1,64 @@
|
|||
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn TakesClone<T: Clone + PartialEq + 'static>(value: T) -> Element {
|
||||
rsx! {}
|
||||
}
|
||||
|
||||
#[derive(Props, Clone, PartialEq)]
|
||||
struct TakesCloneManualProps<T: Clone + PartialEq + 'static> {
|
||||
value: T,
|
||||
}
|
||||
|
||||
fn TakesCloneManual<T: Clone + PartialEq>(props: TakesCloneManualProps<T>) -> Element {
|
||||
rsx! {}
|
||||
}
|
||||
|
||||
#[derive(Props, Clone, PartialEq)]
|
||||
struct TakesCloneManualWhereProps<T>
|
||||
where
|
||||
T: Clone + PartialEq + 'static,
|
||||
{
|
||||
value: T,
|
||||
}
|
||||
|
||||
fn TakesCloneManualWhere<T: Clone + PartialEq>(
|
||||
props: TakesCloneManualWhereProps<T>,
|
||||
) -> Element {
|
||||
rsx! {}
|
||||
}
|
||||
|
||||
#[derive(Props, Clone, PartialEq)]
|
||||
struct TakesCloneManualWhereWithOwnerProps<T>
|
||||
where
|
||||
T: Clone + PartialEq + 'static,
|
||||
{
|
||||
value: EventHandler<T>,
|
||||
}
|
||||
|
||||
fn TakesCloneManualWhereWithOwner<T: Clone + PartialEq>(
|
||||
props: TakesCloneManualWhereWithOwnerProps<T>,
|
||||
) -> Element {
|
||||
rsx! {}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue