-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transparent newtype struct representation #138
Conversation
Thanks! This is a breaking change (however, valid), so I need to test all my dependencies, whether it breaks it and fix them if so. |
I would like to change enum's representation to something like:
@3Hren what do you think? That would make it compatible with Haskell's |
Again, I'm not strictly agains it. All that matters - is backward compatibility. I think we should consider some kind of swappable policies for serialization. Deserialization must support all these ambiguous cases. |
} | ||
other => Err(de::Error::invalid_type(other.unexpected(), &"array")), | ||
} | ||
visitor.visit_newtype_struct(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible to support both old and new deserialization schemes with the cost of some CPU cycles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it would introduce some ambiguity and make it difficult to work with nested types. Handling of something like struct A(Vec<i32>)
would require some code to decode it correctly.
Is it really necessary?
@3Hren what needs to be done to get this merged? |
I'll check in 2 days. Serialization is fine, need to check deserialization. Completely burrowed into other projects :( |
At last I have some free time. Checked - no breaks for me! LGTM. Variants, I think, must behave the same way. Units are doubtful, yeah. Generally speaking for serialization I want to provide options how to serialize ambiguous things, like unit structs. On the other hand deserialization must support all possible variants automatically. I'll do these myself. |
Added in #146. |
#129
Changed encoding of
struct A(B)
from[B]
toB
.This PR is for
newtype struct
only. Variants and units are harder, so I'd like to discuss it first.