serde_as with generic types #663
-
I'm trying to use serde_as with this example from the serde github issues. Where we have a custom deserializer and serializer for pub struct Line<const N: usize> {
#[serde_as(as = "Vec<ArrayVisitor>")]
pub points: Vec<[f64; N]>
} The ArrayVisitor: struct ArrayVisitor<T, const N: usize>(PhantomData<T>); When i try to compile I get the following issue:
How can I pass in the generic types or avoid this? |
Beta Was this translation helpful? Give feedback.
Answered by
jonasbb
Nov 21, 2023
Replies: 1 comment
-
You can specify the generic types on the #[serde_as(as = "Vec<ArrayVisitor<f64, N>>")] The correct values depend on your |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jonasbb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can specify the generic types on the
ArrayVisitor
as usual. Something like this:#[serde_as(as = "Vec<ArrayVisitor<f64, N>>")]
The correct values depend on your
SerializeAs
trait implementation, that you did not provide here.