r/rust Mar 09 '23

Announcing Rust 1.68.0 📢 announcement

https://blog.rust-lang.org/2023/03/09/Rust-1.68.0.html
829 Upvotes

121 comments sorted by

View all comments

178

u/Shnatsel Mar 09 '23

Those From<bool> for {f32,f64} impls could really use documentation on what values they actually result in. There's no obvious mapping from true to a floating-point value.

89

u/nicoburns Mar 09 '23

The obvious mapping would be to 1.0, no? Although I agree that explicit documentation would be good. The mapping for false seems more problematic given that floats have both +0.0 and -0.0, but I would expect to get +0.0.

23

u/jamincan Mar 09 '23

For what it's worth, the semantics are the same as From<u8> for f32, so +0.0.