From 31fd45cc750d4f10da7678183b992baf9fe51234 Mon Sep 17 00:00:00 2001 From: Esteban Dimitroff Hodi Date: Tue, 24 Jun 2025 19:43:23 -0300 Subject: [PATCH] Removed the requirement of implementing Clone on CallMsg and CastMsg --- concurrency/src/tasks/gen_server.rs | 4 ++-- concurrency/src/tasks/time.rs | 3 ++- concurrency/src/threads/gen_server.rs | 4 ++-- concurrency/src/threads/time.rs | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/concurrency/src/tasks/gen_server.rs b/concurrency/src/tasks/gen_server.rs index a72a52a..7c6d01d 100644 --- a/concurrency/src/tasks/gen_server.rs +++ b/concurrency/src/tasks/gen_server.rs @@ -105,8 +105,8 @@ pub trait GenServer where Self: Send + Sized, { - type CallMsg: Clone + Send + Sized + Sync; - type CastMsg: Clone + Send + Sized + Sync; + type CallMsg: Send + Sized + Sync; + type CastMsg: Send + Sized + Sync; type OutMsg: Send + Sized; type State: Clone + Send; type Error: Debug + Send; diff --git a/concurrency/src/tasks/time.rs b/concurrency/src/tasks/time.rs index f26118b..691bf3f 100644 --- a/concurrency/src/tasks/time.rs +++ b/concurrency/src/tasks/time.rs @@ -27,7 +27,7 @@ where Box::pin(cloned_token.cancelled()), Box::pin(async { rt::sleep(period).await; - let _ = handle.cast(message.clone()).await; + let _ = handle.cast(message).await; }), ) .await; @@ -46,6 +46,7 @@ pub fn send_interval( ) -> TimerHandle where T: GenServer + 'static, + T::CastMsg: Clone, { let cancellation_token = CancellationToken::new(); let cloned_token = cancellation_token.clone(); diff --git a/concurrency/src/threads/gen_server.rs b/concurrency/src/threads/gen_server.rs index 9d58754..912067b 100644 --- a/concurrency/src/threads/gen_server.rs +++ b/concurrency/src/threads/gen_server.rs @@ -83,8 +83,8 @@ pub trait GenServer where Self: Send + Sized, { - type CallMsg: Clone + Send + Sized; - type CastMsg: Clone + Send + Sized; + type CallMsg: Send + Sized; + type CastMsg: Send + Sized; type OutMsg: Send + Sized; type State: Clone + Send; type Error: Debug; diff --git a/concurrency/src/threads/time.rs b/concurrency/src/threads/time.rs index 3d47c05..2819bbe 100644 --- a/concurrency/src/threads/time.rs +++ b/concurrency/src/threads/time.rs @@ -41,6 +41,7 @@ pub fn send_interval( ) -> TimerHandle where T: GenServer + 'static, + T::CastMsg: Clone, { let cancellation_token = CancellationToken::new(); let mut cloned_token = cancellation_token.clone();