Closed docwilco closed 2 months ago
You need to switch the order of the macro annotations around. serde_as
must always come before the derive
. The reason is that the macro order is significant in Rust, as the macros are expanded top down. You need to place serde_as
first as it must run before the derive generates all its code, as otherwise the derive will not know about the changed behavior. That should fix everything.
#[serde_as]
#[derive(Deserialize)]
And that was indeed the thing. Any way of making the compiler point that out?
As far as I know this is not possible. The proc-macro cannot tell that the serde derives are "missing" (or already executed). At least not reliably. A warning cannot be printed, since there is no stable API to perform that for a proc-macro, see https://github.com/rust-lang/rust/issues/54140. The only option is a full compile_error!
.
When trying to use
DurationSeconds
withchrono
I get:source for that:
And
Cargo.toml
: