You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am baffled. I can run the examples crate tests just fine.
However, when I run this on my own code, deriving YaDeserialize fails because the constraint of T: YaDeserialize isn't met because T doesn't implement YaDeserialize.
This is for types like i32, String, etc.
I have looked through the code and I don't see anywhere where YaDeserialize is implemented for anything, so I have no idea how the examples crate works, where it has some fields which are String.
*Edit*
I ran cargo-expand, and now understand how it avoids needing to impl YaDeserialize for primitive types. It bakes the from_str directly into the struct's deserialization routine (that seems like it'd cause a lot of unnecessary code duplication, but I guess that pertains to the RFC for the API redesign)
I guess my more fundamental question is:
How can I impl YaDeserialize for a custom type which I basically want to treat as a String it's a specially formatted Timestamp which will always serialize to a String-ish type, and always be parsed from a String-ish type. So it shouldn't have any properties, etc.
At the moment, I'm attempting to duplicate the impl for i32 and string members that I find.
However, I'm not sure how I can direct yaserde_derive::YaDeserialize to fetch the type correctly, since I basically want to treat it as a primitive.
The text was updated successfully, but these errors were encountered:
rrichardson
changed the title
Where are the YaDeserialize impls for primitive types?
Impl YaDeserialize for a type that should be treated as Primitive
Oct 6, 2022
I am baffled. I can run theexamples
crate tests just fine.However, when I run this on my own code, deriving YaDeserialize fails because the constraint of T: YaDeserialize isn't met because T doesn't implement YaDeserialize.This is for types like i32, String, etc.I have looked through the code and I don't see anywhere where YaDeserialize is implemented for anything, so I have no idea how theexamples
crate works, where it has some fields which areString
.*Edit*
I ran cargo-expand, and now understand how it avoids needing to impl YaDeserialize for primitive types. It bakes the from_str directly into the struct's deserialization routine (that seems like it'd cause a lot of unnecessary code duplication, but I guess that pertains to the RFC for the API redesign)
I guess my more fundamental question is:
How can I impl YaDeserialize for a custom type which I basically want to treat as a
String
it's a specially formatted Timestamp which will always serialize to a String-ish type, and always be parsed from a String-ish type. So it shouldn't have any properties, etc.At the moment, I'm attempting to duplicate the impl for i32 and string members that I find.
However, I'm not sure how I can direct
yaserde_derive::YaDeserialize
to fetch the type correctly, since I basically want to treat it as a primitive.The text was updated successfully, but these errors were encountered: