Allow lossless conversions from float into integral types (#3294)
## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here --> 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 <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] 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._
Loading
Please register or sign in to comment