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: Iterator::count #7094

Merged

Conversation

MagisterDallis
Copy link
Contributor

Encountering a compilation panic on this one. I'm wondering if it's because of the unused closure argument?

@reviewable-StarkWare
Copy link

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.

are you based over latest? there was a fix for something similar merged lately.

Reviewed all commit messages.
Reviewable status: 0 of 2 files reviewed, all discussions resolved

Copy link
Contributor Author

@MagisterDallis MagisterDallis left a comment

Choose a reason for hiding this comment

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

yes, this is based on 3e611b5

Reviewable status: 0 of 2 files reviewed, all discussions resolved (waiting on @orizi)

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: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @MagisterDallis)


corelib/src/iter/traits/iterator.cairo line 80 at r1 (raw file):

    ) -> usize {
        let mut self = self;
        Self::fold(ref self, 0_usize, |count, _x| {

can you try removing anything that would need to be inferred?

(specifically - i highly suspect Self::Item of being the culprit of this not working)

Suggestion:

        Self::fold::<usize>(ref self, 0_usize, |count: usize, _x: Self::Item| {

Copy link
Contributor Author

@MagisterDallis MagisterDallis 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: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @orizi)


corelib/src/iter/traits/iterator.cairo line 80 at r1 (raw file):

Previously, orizi wrote…

can you try removing anything that would need to be inferred?

(specifically - i highly suspect Self::Item of being the culprit of this not working)

Even with explicit types, this still happens.

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: 0 of 2 files reviewed, all discussions resolved


corelib/src/iter/traits/iterator.cairo line 80 at r1 (raw file):

Previously, MagisterDallis wrote…

Even with explicit types, this still happens.

Should work now - no need for explicit types.

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.

try again.

Reviewable status: 0 of 2 files reviewed, all discussions resolved

Copy link
Contributor Author

@MagisterDallis MagisterDallis 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: 0 of 2 files reviewed, all discussions resolved (waiting on @orizi)


corelib/src/iter/traits/iterator.cairo line 80 at r1 (raw file):

Previously, orizi wrote…

Should work now - no need for explicit types.

Done. Works

@MagisterDallis MagisterDallis marked this pull request as ready for review January 19, 2025 17:34
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 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MagisterDallis)


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

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 @MagisterDallis)


a discussion (no related file):

Previously, orizi wrote…

@ilyalesokhin-starkware for 2nd eye.

@gilbens-starkware

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 all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MagisterDallis)


corelib/src/iter/traits/iterator.cairo line 56 at r2 (raw file):

    /// The method does no guarding against overflows, so counting elements of
    /// an iterator with more than [`Bounded::<usize>::MAX`] elements either produces the
    /// wrong result or panics.

It will panic, we don't have an option to run with no overflow checks.

Code quote:

    /// an iterator with more than [`Bounded::<usize>::MAX`] elements either produces the
    /// wrong result or panics.

Copy link
Contributor Author

@MagisterDallis MagisterDallis 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, 1 unresolved discussion (waiting on @gilbens-starkware)


corelib/src/iter/traits/iterator.cairo line 56 at r2 (raw file):

Previously, gilbens-starkware (Gil Ben-Shachar) wrote…

It will panic, we don't have an option to run with no overflow checks.

The default implementation will panic but custom implementations might decide to add overflow checks

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.

:lgtm:

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

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 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MagisterDallis)

@gilbens-starkware gilbens-starkware added this pull request to the merge queue Jan 22, 2025
Merged via the queue into starkware-libs:main with commit 1fba5d7 Jan 22, 2025
47 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.

None yet

4 participants