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

Use TryInto for more permissive deserialization for integers #353

Merged
merged 1 commit into from Jun 29, 2022

Conversation

kesyog
Copy link
Contributor

@kesyog kesyog commented Jun 28, 2022

  • Attempt to convert between integer types using TryInto-based
    conversions rather than blanket failing for some source and
    destination types.
  • Use into_uint instead of into_int in Value Deserialize
    implementations for unsigned integer types. Previously, we were
    converting from signed types to unsigned types using as, which can
    lead to surprise integer values conversions (Deserializing into a type with an unsigned integer doesn't give the expected result #93).

Fixes #352 and #93

@kesyog
Copy link
Contributor Author

kesyog commented Jun 28, 2022

* Attempt to convert between integer types using `TryInto`-based
conversions rather than blanket failing for some source and
destination types.
* Use `into_uint` instead of `into_int` in `Value` Deserialize
implementations for unsigned integer types. Previously, we were
converting from signed types to unsigned types using `as`, which can
lead to surprise integer values conversions (mehcode#93).

Fixes mehcode#352 and mehcode#93
@kesyog kesyog force-pushed the kyogeswaran/deserialize-uints branch from a1dd5c7 to 7db2e8b Compare June 29, 2022 03:36
@kesyog
Copy link
Contributor Author

kesyog commented Jun 29, 2022

@matthiasbeyer, I've cleaned up my draft implementation and added a few tests. Your review and CI workflow approval would be appreciated.

Copy link
Collaborator

@matthiasbeyer matthiasbeyer left a comment

Choose a reason for hiding this comment

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

Thank you very much for working on this!

@kesyog
Copy link
Contributor Author

kesyog commented Jun 29, 2022

No problem! It looks like all checks have passed and it's ready for merge whenever you're ready. It'd be great to get the new tests in before #338 to ensure that the functionality doesn't regress.

@matthiasbeyer matthiasbeyer merged commit 2d74d06 into mehcode:master Jun 29, 2022
@matthiasbeyer
Copy link
Collaborator

Yes! #338 has to be rebased onto latest master now, of course 😆

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.

Deserialization fails if set_default is passed an unsigned integer
2 participants