Skip to content

Commit fcfaf4f

Browse files
committed
Add a test for the problem with the serde feature
1 parent 04c7056 commit fcfaf4f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/weird.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use core::fmt::{Debug};
2+
3+
use serde_::{Serialize, Deserialize};
4+
5+
pub trait Protocol<Id> {
6+
type ProtocolError: ProtocolError<Id>;
7+
}
8+
9+
pub trait ProtocolError<Id>: Debug + Clone + Serialize + for<'de> Deserialize<'de> {}
10+
11+
/// A trait defining two protocols executed sequentially.
12+
pub trait ChainedProtocol<Id>: 'static + Debug {
13+
type Protocol1: Protocol<Id>;
14+
}
15+
16+
/// The protocol error type for the chained protocol.
17+
#[derive_where::derive_where(Debug, Clone)]
18+
#[derive(Serialize, Deserialize)]
19+
#[serde(crate = "serde_")]
20+
#[serde(bound(serialize = "
21+
<C::Protocol1 as Protocol<Id>>::ProtocolError: Serialize,
22+
"))]
23+
#[serde(bound(deserialize = "
24+
<C::Protocol1 as Protocol<Id>>::ProtocolError: for<'x> Deserialize<'x>,
25+
"))]
26+
pub enum ChainedProtocolError<Id, C>
27+
where
28+
C: ChainedProtocol<Id>,
29+
{
30+
Protocol1(<C::Protocol1 as Protocol<Id>>::ProtocolError),
31+
}
32+
33+
impl<Id, C> ProtocolError<Id> for ChainedProtocolError<Id, C>
34+
where
35+
C: ChainedProtocol<Id>,
36+
{
37+
38+
}

0 commit comments

Comments
 (0)