rust-num / num-traits

Numeric traits for generic mathematics in Rust
Apache License 2.0
732 stars 135 forks source link

Refactor ToPrimitive range checks #52

Closed cuviper closed 6 years ago

cuviper commented 6 years ago

This is a rebase and continuation of PR #28. The primary benefit is that floats finally check for overflow before casting to integers, avoiding undefined behavior. Fixes #12.

The inter-integer conversions and all of the macros for these have also been tweaked, hopefully improving readability. Exhaustive tests have been added for good and bad conversions around the target MIN and MAX values.

cuviper commented 6 years ago

bors r+

bors[bot] commented 6 years ago

Build succeeded