Closed turalcar closed 1 month ago
Yeah, the difference is a bit of a pain point, though you can always do 1f64.to_string().into()
. I prefer the way this crate does it (with ryu
) since the result is always at most 24 bytes and so can always be inlined. But for this reason, in my projects I have a dedicated function that bypasses to_compact_string
and directly uses ryu
but strips the .0
suffix if it exists.
Thanks for the bug report! @dragazo is right, this is because we use ryu
(see https://github.com/dtolnay/ryu/issues/48) which last I knew offered performance improvements over the implementation in the stdlib.
If having the same behavior as the stdlib
is preferred I'm more than happy to switch implementations
&1f64.to_string() == "1" &1f64.to_compact_string() == "1.0" I don't have a strong preference either way but this makes post-migration regression testing quite a pain.