Deriving `Encode` and `Decode` for generic structures
fwcd opened this issue · 2 comments
fwcd commented
It would be cool if Encode
and Decode
could be derived for generic structures too, e.g.
#[derive(Encode, Decode)]
struct Frame<P> {
id: u8,
payload: P,
}
(Currently this errors with the trait bound P: musli::Encode<M> is not satisfied
, even when specifying a where
constraint on the structure)
udoprog commented
They can!
But you'll have to specify conditional bounds over the relevant generics: https://docs.rs/musli/latest/musli/derives/#muslibound---and-muslidecode_bound--
fwcd commented
Ah thanks, I must have missed that!