-
Notifications
You must be signed in to change notification settings - Fork 549
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(corelib): Iterator::enumerate #7048
feat(corelib): Iterator::enumerate #7048
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @julio4)
a discussion (no related file):
@gilbens-starkware for 2nd eye.
corelib/src/iter/traits/iterator.cairo
line 44 at r1 (raw file):
/// let a = array!['a', 'b', 'c']; /// /// let mut iter = a.into_iter().enumerate();
Suggestion:
/// let mut iter = array!['a', 'b', 'c'].into_iter().enumerate();
corelib/src/test/iter_test.cairo
line 5 at r1 (raw file):
let a = array!['a', 'b', 'c']; let mut iter = a.into_iter().enumerate();
Suggestion:
let mut iter = array!['a', 'b', 'c'].into_iter().enumerate();
There was a problem hiding this 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 @orizi)
corelib/src/iter/traits/iterator.cairo
line 44 at r1 (raw file):
/// let a = array!['a', 'b', 'c']; /// /// let mut iter = a.into_iter().enumerate();
Done.
corelib/src/test/iter_test.cairo
line 5 at r1 (raw file):
let a = array!['a', 'b', 'c']; let mut iter = a.into_iter().enumerate();
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 4 of 6 files reviewed, 3 unresolved discussions (waiting on @julio4 and @orizi)
corelib/src/iter/adapters/enumerate.cairo
line 28 at r2 (raw file):
/// The method does no guarding against overflows, so enumerating more than /// `Bounded::<usize>::MAX` elements either produces the wrong result or panics. If /// debug assertions are enabled, a panic is guaranteed.
We always panic on overflow.
Code quote:
/// `Bounded::<usize>::MAX` elements either produces the wrong result or panics. If
/// debug assertions are enabled, a panic is guaranteed.
There was a problem hiding this 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 r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @julio4)
There was a problem hiding this 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/adapters/enumerate.cairo
line 28 at r2 (raw file):
Previously, gilbens-starkware (Gil Ben-Shachar) wrote…
We always panic on overflow.
Done.
2a49c71
to
5b4800b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 6 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @julio4)
corelib/src/iter/traits/iterator.cairo
line 113 at r3 (raw file):
/// The method does no guarding against overflows, so enumerating more than /// [`Bounded::<usize>::MAX`] elements either produces the wrong result or panics. ///
Same here, also, not sure if the panics section is still needed as this will simply repeat itself.
Code quote:
/// The method does no guarding against overflows, so enumerating more than
/// [`Bounded::<usize>::MAX`] elements either produces the wrong result or panics.
///
5b4800b
to
8502a5b
Compare
8502a5b
to
6622314
Compare
There was a problem hiding this 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 6 files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware and @orizi)
corelib/src/iter/traits/iterator.cairo
line 113 at r3 (raw file):
Previously, gilbens-starkware (Gil Ben-Shachar) wrote…
Same here, also, not sure if the panics section is still needed as this will simply repeat itself.
Done.
I kept the panic section, even if it's slightly redundant at least it's clear that this can panic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 6 files at r3, 3 of 3 files at r4, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @julio4)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @julio4)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r4.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @julio4)
Creates an iterator which gives the current iteration count as well as the next value.
The iterator returned yields pairs
(i, val)
, wherei
is the current index of iteration andval
is the value returned by the iterator.enumerate()
keeps its count as ausize
.Examples
Overflow Behavior
The method does no guarding against overflows, so enumerating more than
Bounded::<usize>::MAX
elements either produces the wrong result or panics.