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

impl num_traits for Quantity. #69

Open
Tehforsch opened this issue Jan 12, 2024 · 0 comments
Open

impl num_traits for Quantity. #69

Tehforsch opened this issue Jan 12, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Tehforsch
Copy link
Owner

Tehforsch commented Jan 12, 2024

As discussed in #55 Quantity should probably implement at least some of the num_traits. In the current implementation, the methods are just anonymous methods that happen to be named the exact same way as the corresponding methods on some of the num traits.

For dimensionless quantities, virtually any traits that f32 fulfills should be possible on Quantity<f32, Dimension::none()> as well.
Mainly I am thinking of

  • Num, NumAssign (and NumAssignOps), NumRef, NumAssignRef RefNum
  • Float if we have either std or num-traits-libm activated, otherwise FloatCore
  • Pow
  • Inv

The following would be possible on all quantities:

  • Signed
  • Euclid

There are a few more and we'd have to look at what we need. For now, I'd probably start by moving the methods that were changed in #55 into the Float trait. Curiously, this trait isn't necessarily unit safe though, because of #57. I suppose we could overlook this for now, but I am not super happy about that.

@Tehforsch Tehforsch added the enhancement New feature or request label Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant