impl Clone manually for EventHandler<Ms>
So Ms doesn't need to impl Clone
@@ -2,13 +2,21 @@ use crate::app::MessageMapper;
use crate::virtual_dom::Ev;
use std::{fmt, rc::Rc};
-#[derive(Clone)]
/// `EventHandler`s are called by DOM event listeners with the same trigger (an event to listen to).
pub struct EventHandler<Ms> {
pub trigger: Ev,
pub callback: Rc<dyn Fn(web_sys::Event) -> Ms>,
}
+impl<Ms> Clone for EventHandler<Ms> {
+ fn clone(&self) -> Self {
+ Self {
+ trigger: self.trigger.clone(),
+ callback: self.callback.clone(),
+ }
+ }
+}
+
impl<Ms> EventHandler<Ms> {
pub fn new(trigger: impl Into<Ev>, callback: impl Fn(web_sys::Event) -> Ms + 'static) -> Self {
Self {
