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

Fix clippy warnings #75

Merged
merged 6 commits into from
Jan 21, 2025
Merged

Fix clippy warnings #75

merged 6 commits into from
Jan 21, 2025

Conversation

sosthene-nitrokey
Copy link
Contributor

Built on top of #74

examples/pwm.rs Outdated
@@ -96,7 +96,7 @@ fn main() -> ! {
}

for i in 0..3 {
let duty = (sin(duties[i] * 3.14159265f32 / 180f32) * 255f32) as u16;
let duty = (sin(duties[i] * 3.141_592_7_f32 / 180f32) * 255f32) as u16;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed value – was that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good catch. That's something that was done by cargo clippy --fix. I think it's because the value is parsed as a f32 then re-encoded, the binary representation of both is the same.

fn main() {
    assert_eq!(3.14159265f32, 3.141_592_7_f32);
}

does not panic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I overlooked that this is only the decimal part. Makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll actually make this use f32::consts::PI.

@sosthene-nitrokey
Copy link
Contributor Author

Hmm, and now I discover that cargo clippy --fix fixes examples, but cargo clippy does not lint them. Fixing that now.

@sosthene-nitrokey sosthene-nitrokey merged commit a338016 into main Jan 21, 2025
4 checks passed
@sosthene-nitrokey sosthene-nitrokey deleted the clippy-warnings branch January 21, 2025 10:36
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

Successfully merging this pull request may close these issues.

2 participants