DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
19.37k stars 747 forks source link

Cannot use EventHandlers with `#[derive(Props)]` #2120

Closed marc2332 closed 3 months ago

marc2332 commented 3 months ago

Problem

Example:

#[derive(Props, PartialEq, Clone)]
pub struct SomeProps<T: 'static + PartialEq + Clone> {
    value: EventHandler<T>,
}

Probably caused by https://github.com/DioxusLabs/dioxus/pull/2119

Expected behavior

Compile

Screenshots

image

Environment:

ealmloff commented 3 months ago

2122 fixes the above code example, but we should probably not require the Clone and PartialEq bounds on T. The Clone and PartialEq derive macros automatically add a where clause that only implements the trait if T: Clone + PartialEq. The Props macro should do something similar