Skip to content
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

Add pass-through for i128/u128 deserialization #7

Merged
merged 1 commit into from
Jun 4, 2020

Conversation

huitseeker
Copy link
Contributor

The default implementation for a deserializer's dispatch of a (i|u)128 is one that Errors out into a Custom message indicating non-support. This enables the common, if debatable, choice of letting implementers avoid bothering with (i|u)128.

But since the present adapter does not implement deserialize_(i|u)128, it also passes to this default behavior, rather than passing through its generic argument, which is the expected behavior of a pass-through.

This PR implements that pass-through. Should the inner serializer then not implement (i|u)128 deserialization, it would default to the common behavior (a custom error), but should it do so (as is crucially the case for libra) it would then function as expected rather than error out.

The [default implementation](https://github.com/serde-rs/serde/blob/33438850a6a8b0a3550619a60885cfc6f224e53f/serde/src/de/mod.rs#L977-L989) for a deserializer's dispatch of a (i|u)128 is one that `Error`s out into a `Custom` message indicating non-support. This enables the common, if debatable, choice of letting implementers avoid bothering with (i|u)128.

 But since the present adapter does not implement `deserialize_(i|u)128`, it also passes to this default behavior, rather than passing through its generic argument, which is the expected behavior of a pass-through.

This PR implements that pass-through. Should the inner serializer then not implement (i|u)128 deserialization, it would default to the common behavior (a custom error), but should it do so (as is crucially the case for libra) it would then function as expected rather than error out.
Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay dtolnay merged commit 7e69f17 into dtolnay:master Jun 4, 2020
@dtolnay
Copy link
Owner

dtolnay commented Jun 4, 2020

Published in 0.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants