From a2a669b205ef99f30185333ab4f9053a5c935541 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Sun, 20 Nov 2022 20:52:16 -0500 Subject: [PATCH] fix: Manually implement clone for actor wrappers This avoids having the compiler require the executor to be clone --- src/util/async_actor/newtype_macro.rs | 6 +++++- src/util/sync_actor/newtype_macro.rs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/util/async_actor/newtype_macro.rs b/src/util/async_actor/newtype_macro.rs index 8869595..aa057c6 100644 --- a/src/util/async_actor/newtype_macro.rs +++ b/src/util/async_actor/newtype_macro.rs @@ -4,8 +4,12 @@ #[macro_export] macro_rules! async_actor { ($type_name:ident, $input_type:ty, $output_type:ty, $context_type:ty, $event_method:ident) => { - #[derive(Clone)] pub struct $type_name(AsyncActor<$input_type, $output_type, X>); + impl Clone for $type_name { + fn clone(&self) -> Self { + Self(self.0.clone()) + } + } impl $type_name { pub fn new(initial_context: $context_type, bound: Option) -> Self { let actor = AsyncActor::spawn_async($event_method, initial_context, bound); diff --git a/src/util/sync_actor/newtype_macro.rs b/src/util/sync_actor/newtype_macro.rs index 9b5b60a..0276e01 100644 --- a/src/util/sync_actor/newtype_macro.rs +++ b/src/util/sync_actor/newtype_macro.rs @@ -4,7 +4,6 @@ #[macro_export] macro_rules! sync_actor { ($type_name:ident, $input_type:ty, $output_type:ty, $context_type:ty, $event_method:ident) => { - #[derive(Clone)] pub struct $type_name(SyncActor<$input_type, $output_type, X>); impl $type_name { pub fn new(initial_context: $context_type, bound: Option) -> Self { @@ -12,6 +11,11 @@ macro_rules! sync_actor { Self(actor) } } + impl Clone for $type_name { + fn clone(&self) -> Self { + Self(self.0.clone()) + } + } #[async_trait] impl EventConsumer<$input_type> for $type_name { type Error = SyncActorError; -- 2.45.2