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

Support all the Rust "math" operations for Numeric<P, S> and AnyNumeric against primitives #1029

Merged
merged 2 commits into from
Feb 2, 2023

Conversation

eeeebbbbrrrr
Copy link
Contributor

@eeeebbbbrrrr eeeebbbbrrrr commented Feb 2, 2023

It was a complete oversight that these didn't get implemented as part of the initial Numeric support back in November 2022 as part of #851.

I was both shocked and awed to learn about this.

So here they are. All of Rust's "math" traits (Add, Sub, Mul, Div, Rem) are implemented for both Numeric<P, S> and AnyNumeric against all rust primitive types, with the primitive supported on both the left and right.

In all cases, the resulting datatype is an AnyNumeric.

…meric` on the left and each Rust primitive type on the right
Copy link
Contributor

@thomcc thomcc left a comment

Choose a reason for hiding this comment

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

LGTM. There are probably ways to reduce the boilerplate further (with another layer of macro nonsense), but it's your call if you want to try for that (it's not exactly unclear as-is).

@eeeebbbbrrrr
Copy link
Contributor Author

I'm gonna do the reverse to have the primitive on the lhs and call it a day.

…meric` on the right and each Rust primitive type on the left
@eeeebbbbrrrr eeeebbbbrrrr merged commit 9e358af into develop Feb 2, 2023
@eeeebbbbrrrr eeeebbbbrrrr deleted the more-numeric-math branch June 20, 2023 17:59
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