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

Allow lossless conversions from float into integral types #3294

Merged
merged 3 commits into from
Dec 8, 2023

Conversation

rcoh
Copy link
Collaborator

@rcoh rcoh commented Dec 7, 2023

Motivation and Context

Some APIs return JSON values that are intended to be represented by integral types but are returned as floating values e.g [1.0, -2.0, 25.0].

This allows those values to be converted into Integral types.

Description

This uses a bidirectional conversion to check if a float can be losslessly converted into a integral type. This can have issues at the limits of i64::MAX but I think that's probably acceptable. These values would be represented imprecisely by floats already.

Testing

Added additional unit tests of the behavior.

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates
  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@rcoh rcoh force-pushed the lossless-runtime-conversions branch from 76378d1 to f082228 Compare December 7, 2023 18:46
Copy link

github-actions bot commented Dec 7, 2023

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@rcoh rcoh force-pushed the lossless-runtime-conversions branch from f082228 to dcbd671 Compare December 7, 2023 20:31
@rcoh rcoh marked this pull request as ready for review December 7, 2023 20:32
@rcoh rcoh requested review from a team as code owners December 7, 2023 20:32
@jdisanti
Copy link
Collaborator

jdisanti commented Dec 7, 2023

Looks good. Don't forget the changelog entry.

Copy link

github-actions bot commented Dec 7, 2023

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@rcoh rcoh requested a review from david-perez December 7, 2023 21:25
Copy link

github-actions bot commented Dec 7, 2023

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@rcoh rcoh added this pull request to the merge queue Dec 8, 2023
Merged via the queue into main with commit b09b02f Dec 8, 2023
41 checks passed
@rcoh rcoh deleted the lossless-runtime-conversions branch December 8, 2023 15:45
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.

4 participants