Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is arguably no obvious mapping from a Boolean to a float so implementation of From<bool> for f32 and f64 should document its outputs #108939

Closed
bmoxb opened this issue Mar 9, 2023 · 2 comments · Fixed by #108946
Assignees
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools A-floating-point Area: Floating point numbers and arithmetic

Comments

@bmoxb
Copy link
Contributor

bmoxb commented Mar 9, 2023

Location

https://doc.rust-lang.org/stable/std/primitive.f32.html#impl-From%3Cbool%3E-for-f32

Summary

In Rust 1.68.0, From<bool> is implemented on f32 and f64. It is not very clear how a Boolean value could be converted into a float and the documentation offers no explanation - I had to look at the actual implementation to figure out the output value. It seems sensible that the output of this implementation of From be given in the documentation.

@bmoxb bmoxb added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Mar 9, 2023
@workingjubilee workingjubilee added the A-floating-point Area: Floating point numbers and arithmetic label Mar 9, 2023
@cuviper
Copy link
Member

cuviper commented Mar 9, 2023

From<bool> for {integer} docs say, "The resulting value is 0 for false and 1 for true values." We should add similar statements for floats.

@bmoxb
Copy link
Contributor Author

bmoxb commented Mar 9, 2023

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools A-floating-point Area: Floating point numbers and arithmetic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants