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 num::traits::ops::OverflowingAdd trait #4988

Merged
merged 2 commits into from
Feb 19, 2024

Conversation

enitrat
Copy link
Contributor

@enitrat enitrat commented Feb 4, 2024

Adds a trait for overflowing add operations.

This is particularly useful when writing generic implementations that require wrapping or overflowing operations.
Once discussed and approved, I will also work on OverflowingSub, OverflowingMul traits, and later on on Wrapping traits.


This change is Reviewable

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 5 of 5 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @enitrat)


corelib/src/num/traits/ops/overflowing.cairo line 3 at r1 (raw file):

/// Performs addition with a flag for overflow.
pub trait OverflowingAdd<T> {
    /// Returns a tuple of the sum along with a boolean indicating whether an arithmetic overflow would occur.

Suggestion:

    /// Returns a tuple of the sum along with a boolean indicating whether an arithmetic overflow
    /// would occur.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @enitrat)

a discussion (no related file):
@gilbens-starkware for 2nd eye.


Copy link
Contributor

@gilbens-starkware gilbens-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 5 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @enitrat)


corelib/src/integer.cairo line 2750 at r1 (raw file):

// OverflowingAdd implementations

impl U8OverflowingAdd of core::num::traits::OverflowingAdd<u8> {

Suggestion:

// OverflowingAdd implementations
impl U8OverflowingAdd of core::num::traits::OverflowingAdd<u8> {

Copy link
Contributor Author

@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.

Reviewable status: 3 of 5 files reviewed, 2 unresolved discussions (waiting on @orizi)


corelib/src/num/traits/ops/overflowing.cairo line 3 at r1 (raw file):

/// Performs addition with a flag for overflow.
pub trait OverflowingAdd<T> {
    /// Returns a tuple of the sum along with a boolean indicating whether an arithmetic overflow would occur.

Done.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @enitrat)

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @enitrat)

Copy link
Contributor

@gilbens-starkware gilbens-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 5 files at r1, 1 of 2 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @enitrat)

@gilbens-starkware gilbens-starkware added this pull request to the merge queue Feb 19, 2024
Merged via the queue into starkware-libs:main with commit 711d97b Feb 19, 2024
43 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.

3 participants