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

feat: Add WrappingMath trait #241

Merged
merged 5 commits into from
Jan 15, 2024

Conversation

Hyodar
Copy link
Contributor

@Hyodar Hyodar commented Jan 14, 2024

Add WrappingMath trait

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Individual functions for wrapping ops in uints.

Issue Number: #214

What is the new behavior?

Adds a WrappingMath trait on math and implements it for uints. It provides wrapping_add, wrapping_sub and wrapping_mul, removing the need to use type-specific wrapping operations like u64_wrapping_add.

I added it directly to math, since I wasn't totally sure where would be the best module to keep this. Feel free to move / ask me to move it somewhere else.

(edit: Also adds individual traits for each operation: WrappingAdd, WrappingSub and WrappingMul)

Does this introduce a breaking change?

  • Yes
  • No

@Hyodar Hyodar requested a review from 0xLucqs as a code owner January 14, 2024 16:05
@Hyodar Hyodar changed the title Add WrappingMath trait feat: Add WrappingMath trait Jan 14, 2024
src/math/src/lib.cairo Outdated Show resolved Hide resolved
src/math/src/lib.cairo Outdated Show resolved Hide resolved
src/math/src/tests/math_test.cairo Outdated Show resolved Hide resolved
Copy link
Collaborator

@enitrat enitrat left a comment

Choose a reason for hiding this comment

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

💯 (but I dont actually have approval rights 😄 )

@0xLucqs 0xLucqs merged commit 98aadc7 into keep-starknet-strange:main Jan 15, 2024
3 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants