Skip to content

Introduce Decimal helper type #34

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

Merged
merged 1 commit into from
Aug 14, 2023
Merged

Introduce Decimal helper type #34

merged 1 commit into from
Aug 14, 2023

Conversation

adampetro
Copy link
Contributor

Introduce a helper type for Decimal scalars to handle conversion to/from f64.

Note that in this implementation, it removes the Eq implementation in generate_types! because f64 does not implement Eq. Hopefully this is not an issue as we'll still have PartialEq which goes a long way.

Copy link
Member

@surma surma left a comment

Choose a reason for hiding this comment

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

Looking good, although I wonder if it might be handy to implement Deref<Target = f64> for this type. We’d get most of the behavior for free.

@adampetro
Copy link
Contributor Author

Looking good, although I wonder if it might be handy to implement Deref<Target = f64> for this type. We’d get most of the behavior for free.

I had this in a previous iteration but opted to remove it based on this guidance on Deref usage from the docs:

Deref should only be implemented for smart pointers to avoid confusion.

But I don't have a strong opinion on this and I'm happy to add it if you think it would be beneficial.

Copy link
Contributor

@andrewhassan andrewhassan left a comment

Choose a reason for hiding this comment

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

LGTM!

For release, this is technically a breaking change, right? Partners will have to update their Rust code to use Decimal instead of String, right?

@adampetro
Copy link
Contributor Author

For release, this is technically a breaking change, right? Partners will have to update their Rust code to use Decimal instead of String, right?

Yes. But since it's pre-1.0 I think it's ok to have breaking changes in a "minor" version bump.

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.

3 participants