-
Notifications
You must be signed in to change notification settings - Fork 531
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): Option iterator #6942
base: main
Are you sure you want to change the base?
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 all commit messages.
Reviewable status: 0 of 2 files reviewed, 3 unresolved discussions (waiting on @cairolover)
corelib/src/test/option_test.cairo
line 146 at r1 (raw file):
let x: Option<u32> = Option::Some(5); let mut x_iter = x.into_iter(); assert!(x_iter.next() == Option::Some(5));
Suggestion:
assert!(x_iter.next() == Option::Some(5));
assert!(x_iter.next() == Option::None);
corelib/src/option.cairo
line 479 at r1 (raw file):
fn next(ref self: OptionIter<T>) -> Option<T> { self.inner }
Suggestion:
impl OptionIterator<T> of Iterator<OptionIter<T>> {
type Item = T;
fn next(ref self: OptionIter<T>) -> Option<T> {
let item = self.inner;
self.inner = Option::None;
item
}
corelib/src/option.cairo
line 489 at r1 (raw file):
OptionIter { inner: self } } }
Suggestion:
impl OptionIntoIterator<T> of IntoIterator<Option<T>> {
type IntoIter = OptionIter<T>;
#[inline]
fn into_iter(self: Option<T>) -> OptionIter<T> {
OptionIter { inner: self }
}
}
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: 0 of 2 files reviewed, 3 unresolved discussions (waiting on @orizi)
corelib/src/test/option_test.cairo
line 146 at r1 (raw file):
let x: Option<u32> = Option::Some(5); let mut x_iter = x.into_iter(); assert!(x_iter.next() == Option::Some(5));
Done.
corelib/src/option.cairo
line 479 at r1 (raw file):
fn next(ref self: OptionIter<T>) -> Option<T> { self.inner }
Done.
corelib/src/option.cairo
line 489 at r1 (raw file):
OptionIter { inner: self } } }
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.
Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @cairolover)
corelib/src/option.cairo
line 147 at r2 (raw file):
//! [`into_iter`]: IntoIterator::into_iter use crate::iter::{IntoIterator, Iterator};
probably remove the import itself - for the time being - in general until we break version 2023_01 where visibility modifiers will be ignored, we attempt to reduce the number of use
s - as they add an actual viewable item in that case. (and here you use these still only once)
Code quote:
use crate::iter::{IntoIterator, Iterator};
af14d84
to
5222b53
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: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @orizi)
corelib/src/option.cairo
line 147 at r2 (raw file):
Previously, orizi wrote…
probably remove the import itself - for the time being - in general until we break version 2023_01 where visibility modifiers will be ignored, we attempt to reduce the number of
use
s - as they add an actual viewable item in that case. (and here you use these still only once)
Done.
394b606
to
fd34fae
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: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @orizi)
corelib/src/option.cairo
line 147 at r2 (raw file):
Previously, cairolover (cairolover) wrote…
Done.
by the way - shouldn't iterator traits be part of the prelude?
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 r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @cairolover)
corelib/src/option.cairo
line 147 at r2 (raw file):
Previously, cairolover (cairolover) wrote…
by the way - shouldn't iterator traits be part of the prelude?
quite possibly it would make more sense.
a discussion (no related file):
@enitrat for 2nd eye doc.
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 @cairolover)
fd34fae
to
b554749
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 1 of 2 files at r4, all commit messages.
Reviewable status: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @cairolover)
corelib/src/test/option_test.cairo
line 1 at r4 (raw file):
use crate::iter::{IntoIterator, Iterator};
i believe shouldn't be required after rebase.
Code quote:
use crate::iter::{IntoIterator, Iterator};
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: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @orizi)
corelib/src/test/option_test.cairo
line 1 at r4 (raw file):
Previously, orizi wrote…
i believe shouldn't be required after rebase.
The other one has not been merged yet. I'll revisit once it is
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: 1 of 2 files reviewed, all discussions resolved (waiting on @cairolover)
a discussion (no related file):
@gilbens-starkware for 2nd eye.
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: 1 of 2 files reviewed, all discussions resolved (waiting on @orizi)
Adds
IntoIter
andIterator
implementations forOption<T>