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

Apply clippy::cast_lossless to make code more readable #1245

Open
CrazyboyQCD opened this issue Jun 24, 2024 · 2 comments
Open

Apply clippy::cast_lossless to make code more readable #1245

CrazyboyQCD opened this issue Jun 24, 2024 · 2 comments

Comments

@CrazyboyQCD
Copy link

CrazyboyQCD commented Jun 24, 2024

Lint link.
Since there are plenty of as statments I think distinguishing between safe(lossless) conversion and coercion would make the code more readable.

Clippy should fix most of them:

cargo clippy --fix -- -D clippy::cast_lossless 

Left case(s) by clippy: link

@kkysen
Copy link
Collaborator

kkysen commented Jun 25, 2024

This might be useful; thanks for letting us know about it! That said, there are necessarily a lot of [_ as usize] casts and this might make that pretty noisy. We'll definitely think about it, though, as I agree it makes things more readable in a lot of cases.

@CrazyboyQCD
Copy link
Author

This might be useful; thanks for letting us know about it! That said, there are necessarily a lot of [_ as usize] casts and this might make that pretty noisy. We'll definitely think about it, though, as I agree it makes things more readable in a lot of cases.

I tested it and found [_ as usize] will not be affected mentioned in the link above, so apply it will not mess that up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants