~thatonelutenist/actm

a2a669b205ef99f30185333ab4f9053a5c935541 — Nathan McCarty 1 year, 9 months ago d893c8d
fix: Manually implement clone for actor wrappers

This avoids having the compiler require the executor to be clone
2 files changed, 10 insertions(+), 2 deletions(-)

M src/util/async_actor/newtype_macro.rs
M src/util/sync_actor/newtype_macro.rs
M src/util/async_actor/newtype_macro.rs => src/util/async_actor/newtype_macro.rs +5 -1
@@ 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<X: Executor>(AsyncActor<$input_type, $output_type, X>);
        impl<X: Executor> Clone for $type_name<X> {
            fn clone(&self) -> Self {
                Self(self.0.clone())
            }
        }
        impl<X: Executor> $type_name<X> {
            pub fn new(initial_context: $context_type, bound: Option<usize>) -> Self {
                let actor = AsyncActor::spawn_async($event_method, initial_context, bound);

M src/util/sync_actor/newtype_macro.rs => src/util/sync_actor/newtype_macro.rs +5 -1
@@ 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<X: Executor>(SyncActor<$input_type, $output_type, X>);
        impl<X: Executor> $type_name<X> {
            pub fn new(initial_context: $context_type, bound: Option<usize>) -> Self {


@@ 12,6 11,11 @@ macro_rules! sync_actor {
                Self(actor)
            }
        }
        impl<X: Executor> Clone for $type_name<X> {
            fn clone(&self) -> Self {
                Self(self.0.clone())
            }
        }
        #[async_trait]
        impl<X: Executor> EventConsumer<$input_type> for $type_name<X> {
            type Error = SyncActorError;