Open DCNick3 opened 1 month ago
To not reimplement the whole
serde
in this crate, you can just emit the corresponding#[serde(bounds)]
and hand off the rest to the upstream derive macro
We talked about this a long time ago and our main reason not to do this was that reimplementing Serde would be an ungodly amount and error-prone work. But just emitting the corresponding attributes might be reasonable.
I would have to take a deeper look, but in favor.
It doesn't sound too bad to do, and you are probably right that it wouldn't be possible to emit serde's syntax with declarative macros, because string concatenation only works in certain positions (like the built-in doc
attribute).
I tried implementing this as part of derive-where
, but a big chunk of the code is coupled tightly to generating actual impl blocks, not emitting attributes. I am not familiar with the codebase, so I was not able to come up with a localized API change that would work here
Would it be possible to support serde derive macros (
Serialize
&Deserialize
) inderive-where
?Currently, if you put fields from associated types, you have to manually put
#[serde(bounds(serialize = "XXX: Serialize", deserialize = "XXX: Deserialize<'de>"))]
, which can amount to a lot of boilerplate, and might not even be possible to generate in declarative macros (at least I didn't find any way to).To not reimplement the whole
serde
in this crate, you can just emit the corresponding#[serde(bounds)]
and hand off the rest to the upstream derive macro