From 63379ed09405f0f0fbd06603214d5cab794ee4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=82=8E=E6=B3=BC?= Date: Wed, 17 Jan 2024 20:15:49 +0800 Subject: [PATCH] Refactor: RaftError: serde derive The problem is not the bound on the `E` generic, but rather, the fact that `NID` is receiving two different `Serialize/Deserialize` bounds; one from the derive annotation, and one from the `NID: NodeId` trait bound. This modification is from suggestions by @tvsfs about the serde bound: https://github.com/datafuselabs/openraft/pull/991#issuecomment-1895674216 --- openraft/src/error.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/openraft/src/error.rs b/openraft/src/error.rs index ad6a013d3..a3ac384f6 100644 --- a/openraft/src/error.rs +++ b/openraft/src/error.rs @@ -24,18 +24,14 @@ use crate::Vote; /// It is either a Fatal error indicating that `Raft` is no longer running, such as underlying IO /// error, or an API error `E`. #[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] -#[cfg_attr( - feature = "serde", - derive(serde::Deserialize, serde::Serialize), - serde(bound(serialize = "E: serde::Serialize")), - serde(bound(deserialize = "E: for <'d> serde::Deserialize<'d>")) -)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub enum RaftError where NID: NodeId { #[error(transparent)] APIError(E), + #[serde(bound = "")] #[error(transparent)] Fatal(#[from] Fatal), }