-
-
Notifications
You must be signed in to change notification settings - Fork 791
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
Error deserializing the unit type from an empty sequence #2340
Comments
Actually ability to deserialize However, there is still some inconsistency. Internal Lines 1297 to 1345 in 05a5b7e
This is required, because this deserializer is used for internally tagged enums: #[derive(Deserialize)]
#[serde(tag = "tag")]
enum InternallyTagged {
Unit,
} where However, |
If I unterstand you correctly, you argue that |
I would not say what I argue, but this is the current behavior which was implemented in this way with such motivation. I actually agree with you, that it would be feasible to have |
I will draft a PR if I find time. |
I stumbled across the following inconsistency in serde and wondered if this is a bug or not:
AFAIK the unit type is can be thought of a tuple of length 0 and there is no other way to express that in rust. But while deserialization of tuples with elements works fine, deserializing an empty sequence into a unit type fails. I know that I could work around this in various ways but this behaviour does not seem to be correct.
I found out about this behaviour while writing a macro where I deserialize function arguments into tuples.
Any thoughts?
The text was updated successfully, but these errors were encountered: