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

Decimal and Foundation #122

Merged
merged 5 commits into from
Oct 31, 2024
Merged

Decimal and Foundation #122

merged 5 commits into from
Oct 31, 2024

Conversation

mredig
Copy link
Contributor

@mredig mredig commented Oct 29, 2024

I'm using this package in another package I'm working on and found myself needing to support Decimal.

While I was poking around, I also happened to notice that Foundation is very sparsely used, and therefore was easy to conditionalize for environments where Foundation might not be available (in theory, I think this might build for microcontrollers now without the Foundation features, but I have admittedly not tested it).

So this is obviously more than a small, itty bitty, incremental update, but has a few, only tangentially related features:

  • Support for initializing from Decimal
    • I used a pretty naive solution, but it works
    • (requires Foundation, but...)
  • Conditionally builds with Foundation features, when #if canImport(Foundation) is true. Otherwise, everything else is all pure Swift (citation needed)
  • DRYed up the Data serialization and initializers, since they were right where I was working to conditionalize Foundation.
  • DRYed up some of the FloatingPoint initializers, as a lot of the code was the same between the new Decimal inits and the existing ones.
  • Added CustomDebugStringConvertible conformance, keeping it DRY with the existing Playground descriptions.

I completely understand if you don't want some, or even all of these changes and I'm happy to tweak the PR to accommodate, but I'll just have to use my own fork for my own needs then :)

@mredig
Copy link
Contributor Author

mredig commented Oct 29, 2024

Oh - also noteworthy - I added tests for the new stuff and confirmed all tests pass on my computer.

Copy link
Collaborator

@tgymnich tgymnich left a comment

Choose a reason for hiding this comment

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

This is great. Thank you! Just one small thing.

@tgymnich tgymnich merged commit a7ee114 into attaswift:master Oct 31, 2024
4 checks passed
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