-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
From<bool> for integers not implemented? #46109
Comments
IIRC, the integer value of Addendum: in fact, the compiler is now taking advantage of this undefinedness: #45225 I guess the impl could be as simple as |
But none of this is really related to this issue. IMO clippy is being silly and you should just use |
Is this issue beginner-friendly? I could work on it with some guidance. |
In #50597 I propose to use There is a discussion for this topic on internals.rust-lang.org and a use case here : https://github.com/ithinuel/rusty-printer You'll need to build rust with the target |
Add From<bool> for int types Fixes #46109.
Add From<bool> for int types Fixes #46109.
I would find it incredibly useful to being able to cast a bool to another type so I can shift it around to generate bitmasks but ALAS this is not possible at the moment due to missing From trait impls:
Using
as
instead works fine but is frowned upon by clippy if the type is not a bool but a different type instead:Since the code in question is automatically generated it would be great if there was one common implementation that can (and should) be used for all types.
The text was updated successfully, but these errors were encountered: