From e37856a855185c496013bdb0009fb0a807396d25 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Fri, 7 Sep 2018 11:10:30 +0200 Subject: [PATCH] Remove Clone impl for WebGLMsg --- components/canvas_traits/webgl.rs | 4 ++-- components/canvas_traits/webgl_channel/mod.rs | 14 +++++++++++++- components/canvas_traits/webgl_channel/mpsc.rs | 7 ++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs index bdffd586287..89fec5596cd 100644 --- a/components/canvas_traits/webgl.rs +++ b/components/canvas_traits/webgl.rs @@ -24,7 +24,7 @@ pub use ::webgl_channel::WebGLPipeline; pub use ::webgl_channel::WebGLChan; /// WebGL Message API -#[derive(Clone, Deserialize, Serialize)] +#[derive(Deserialize, Serialize)] pub enum WebGLMsg { /// Creates a new WebGLContext. CreateContext(WebGLVersion, Size2D, GLContextAttributes, @@ -155,7 +155,7 @@ impl WebGLMsgSender { } /// WebGL Commands for a specific WebGLContext -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize)] pub enum WebGLCommand { GetContextAttributes(WebGLSender), ActiveTexture(u32), diff --git a/components/canvas_traits/webgl_channel/mod.rs b/components/canvas_traits/webgl_channel/mod.rs index f317d116f3d..3c6bd1690b0 100644 --- a/components/canvas_traits/webgl_channel/mod.rs +++ b/components/canvas_traits/webgl_channel/mod.rs @@ -16,12 +16,24 @@ lazy_static! { static ref IS_MULTIPROCESS: bool = { opts::multiprocess() }; } -#[derive(Clone, Deserialize, Serialize)] +#[derive(Deserialize, Serialize)] pub enum WebGLSender { Ipc(ipc::WebGLSender), Mpsc(mpsc::WebGLSender), } +impl Clone for WebGLSender +where + T: Serialize, +{ + fn clone(&self) -> Self { + match *self { + WebGLSender::Ipc(ref chan) => WebGLSender::Ipc(chan.clone()), + WebGLSender::Mpsc(ref chan) => WebGLSender::Mpsc(chan.clone()), + } + } +} + impl fmt::Debug for WebGLSender { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "WebGLSender(..)") diff --git a/components/canvas_traits/webgl_channel/mpsc.rs b/components/canvas_traits/webgl_channel/mpsc.rs index 79988835b6c..92b83791d36 100644 --- a/components/canvas_traits/webgl_channel/mpsc.rs +++ b/components/canvas_traits/webgl_channel/mpsc.rs @@ -26,10 +26,15 @@ macro_rules! unreachable_serializable { }; } -#[derive(Clone)] pub struct WebGLSender(mpsc::Sender); pub struct WebGLReceiver(mpsc::Receiver); +impl Clone for WebGLSender { + fn clone(&self) -> Self { + WebGLSender(self.0.clone()) + } +} + impl WebGLSender { #[inline] pub fn send(&self, data: T) -> Result<(), mpsc::SendError> {