From 4758e2ff75fc947f0c4a54d8efd87caf4db2afa2 Mon Sep 17 00:00:00 2001 From: Elliott Mahler <join.together@gmail.com> Date: Sun, 12 Jan 2020 19:46:47 -0800 Subject: [PATCH] Additional clone removals for wasm --- web/src/bus.rs | 2 +- web/src/lib.rs | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/web/src/bus.rs b/web/src/bus.rs index 1b650b28..09908679 100644 --- a/web/src/bus.rs +++ b/web/src/bus.rs @@ -15,7 +15,7 @@ pub struct Bus<Message> { impl<Message> Bus<Message> where - Message: 'static + Clone, + Message: 'static, { pub(crate) fn new() -> Self { Self { diff --git a/web/src/lib.rs b/web/src/lib.rs index d4c422d2..7ea22e85 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -91,7 +91,7 @@ pub trait Application { /// The type of __messages__ your [`Application`] will produce. /// /// [`Application`]: trait.Application.html - type Message: Clone; + type Message; /// Initializes the [`Application`]. /// @@ -148,16 +148,26 @@ pub trait Application { } } -#[derive(Clone)] + struct Instance<Message> { title: String, ui: Rc<RefCell<Box<dyn Application<Message = Message>>>>, vdom: Rc<RefCell<Option<dodrio::VdomWeak>>>, } +impl<Message> Clone for Instance<Message> { + fn clone(&self) -> Self { + Self { + title: self.title.clone(), + ui: Rc::clone(&self.ui), + vdom: Rc::clone(&self.vdom), + } + } +} + impl<Message> Instance<Message> where - Message: 'static + Clone, + Message: 'static { fn new(ui: impl Application<Message = Message> + 'static) -> Self { Self { @@ -221,7 +231,7 @@ where impl<Message> dodrio::Render for Instance<Message> where - Message: 'static + Clone, + Message: 'static, { fn render<'a, 'bump>( &'a self,