From 8dae9ac6c95a5ae1a7045450aad3d3db57e0c3bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=82=8E=E6=B3=BC?= Date: Fri, 16 Jun 2023 18:12:42 +0800 Subject: [PATCH] Improve: impl Clone for Raft does not require Clone for its type parameters Thanks to [xDarksome](https://github.com/xDarksome) - Fix: #870 --- openraft/src/raft.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/openraft/src/raft.rs b/openraft/src/raft.rs index fa8d544b6..ed7d0411b 100644 --- a/openraft/src/raft.rs +++ b/openraft/src/raft.rs @@ -190,7 +190,6 @@ where /// `shutdown` method should be called on this type to await the shutdown of the node. If the parent /// application needs to shutdown the Raft node for any reason, calling `shutdown` will do the /// trick. -#[derive(Clone)] pub struct Raft where C: RaftTypeConfig, @@ -202,6 +201,21 @@ where _phantom: PhantomData, } +impl Clone for Raft +where + C: RaftTypeConfig, + N: RaftNetworkFactory, + LS: RaftLogStorage, + SM: RaftStateMachine, +{ + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + _phantom: PhantomData, + } + } +} + impl Raft where C: RaftTypeConfig,