dtolnay / ryu

Fast floating point to string conversion
Apache License 2.0
606 stars 27 forks source link

Improve safety by removing transmutes and making deubug_asserts more strict #32

Closed pheki closed 4 years ago

pheki commented 4 years ago

Current code was using transmute to get the bit-pattern of f32 and f64.

This PR changes to use .to_bits() instead, which has that exact semantic, is safe and supported since rustc 1.20. It also makes two debug_assert!()s stricter as they were not strict enough when compared to the get_unchecked right next to it.

Thanks a lot!