Document the resulting values produced when using From<bool> on floats

This commit is contained in:
bmoxb 2023-03-09 18:55:28 +00:00
parent 39f2657d11
commit d5bb6056f1

View File

@ -172,7 +172,8 @@ impl_from! { f32, f64, #[stable(feature = "lossless_float_conv", since = "1.6.0"
#[stable(feature = "float_from_bool", since = "1.68.0")] #[stable(feature = "float_from_bool", since = "1.68.0")]
#[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")] #[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")]
impl const From<bool> for f32 { impl const From<bool> for f32 {
/// Converts `bool` to `f32` losslessly. /// Converts `bool` to `f32` losslessly. The resulting value is `0.0` for
/// `false` and `1.0` for `true` values.
#[inline] #[inline]
fn from(small: bool) -> Self { fn from(small: bool) -> Self {
small as u8 as Self small as u8 as Self