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

Implement clamp for f64 Quantities #476

Closed
kylecarow opened this issue Jun 7, 2024 · 1 comment
Closed

Implement clamp for f64 Quantities #476

kylecarow opened this issue Jun 7, 2024 · 1 comment

Comments

@kylecarow
Copy link

kylecarow commented Jun 7, 2024

Recently tried to use clamp on an f64 quantity, but ran into this issue:

Quantity::clamp is only implemented via the Ord trait:
impl Ord for Quantity

f64 and f32 implement clamp manually (which makes sense, as they aren't Ord - though I'm unsure why clamp couldn't have been implemented in PartialOrd given that it only uses PartialOrd comparisons, oh well)
f64::clamp
f32::clamp

Could clamp (and maybe similar methods) be implemented for f64 Quantities? This would be used widely throughout my code, where I otherwise have doubled-up min/max calls.

@iliekturtles
Copy link
Owner

Closing as a duplicate of #239. Draft PR is available at #377, but I just haven't pushed it over the finish line.

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