What are your thoughts on using struct SessionType<B : Bound>
where Bound
is implemented by only one struct ConcreteBound
instead of just SessionType<ConcreteBound>
directly?
E.g. instead of implemenating:
impl Deserialize for SessionType<ConcreteBound> {
// ..
}
doing:
impl<V> Deserialize for SessionType<V> where V : Bound {
// ..
}
impl Bound for ConcreteBound {}
The primary motivation is that serde
's derive macros do already support trait based bounds, eg. #[serde(bound(deserialize = "V: Bound"))
while they do not support concrete type bound like #[serde(bound_type(deserialize = "ConcreteBound"))]
I suggested here: derive `Deserialize` only for specific session types · Issue #2869 · serde-rs/serde · GitHub . So downstream consumers of SessionType
could use serde's derive macro:
#[derive(Deserialize)]
#[serde(bound(deserialize = "V: Bound"))]
struct DownstreamType<V : Bound> {
foo: SessionType<V>
// ..
}
While with the concrete type, they are stuck manually implemenating Deserialize
on a DownstreamType<ConcreteBound>
.
Do you see any downsides or problems to using impl X for SessionType<B : Bound>
?