-
Notifications
You must be signed in to change notification settings - Fork 562
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::collect #7086
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.
the first one is definitely the correct one - but some inference is probably missing.
added some specific suggestions.
Reviewed 1 of 3 files at r1, all commit messages.
Reviewable status: 1 of 3 files reviewed, 4 unresolved discussions (waiting on @julio4)
corelib/src/test/iter_test.cairo
line 17 at r1 (raw file):
assert_eq!(*arr[0], 0); assert_eq!(*arr[1], 1); assert_eq!(*arr[2], 2);
Suggestion:
assert_eq!((0..3_u32).into_iter().collect(), array![0, 1, 2]);
corelib/src/iter/traits/iterator.cairo
line 99 at r1 (raw file):
#[inline] #[must_use] fn collect<B, +FromIterator<B, Self::Item>, +Drop<T>>(
Suggestion:
fn collect<B, +FromIterator<B, Self::Item>, +Destruct<T>>(
corelib/src/iter/traits/iterator.cairo
line 99 at r1 (raw file):
#[inline] #[must_use] fn collect<B, +FromIterator<B, Self::Item>, +Drop<T>>(
doc
corelib/src/iter/traits/iterator.cairo
line 102 at r1 (raw file):
self: T, ) -> B { FromIterator::from_iter(self)
Suggestion:
FromIterator::<B, Self::Item>::from_iter::<T, Self>(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: 1 of 3 files reviewed, 4 unresolved discussions (waiting on @orizi)
corelib/src/test/iter_test.cairo
line 17 at r1 (raw file):
assert_eq!(*arr[0], 0); assert_eq!(*arr[1], 1); assert_eq!(*arr[2], 2);
Done.
corelib/src/iter/traits/iterator.cairo
line 99 at r1 (raw file):
#[inline] #[must_use] fn collect<B, +FromIterator<B, Self::Item>, +Drop<T>>(
Done.
corelib/src/iter/traits/iterator.cairo
line 102 at r1 (raw file):
self: T, ) -> B { FromIterator::from_iter(self)
I still have some issues (reported from the lsp, compilation fails without any diagnostics)
B
: Type not found.from_iter
: Trait has no implementation in context: core::iter::traits::collect::FromIterator::<, Iterator::Item>.Self
: Unknown impl.
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 3 files reviewed, 4 unresolved discussions (waiting on @julio4)
corelib/src/iter/traits/iterator.cairo
line 102 at r1 (raw file):
Previously, julio4 (Julio) wrote…
I still have some issues (reported from the lsp, compilation fails without any diagnostics)
B
: Type not found.from_iter
: Trait has no implementation in context: core::iter::traits::collect::FromIterator::<, Iterator::Item>.Self
: Unknown impl.
yes - it seems that finding Self
as an impl in trait context is yet to be supported.
working on it.
note:
please don't mention errors you got from the LSP - as this may not be the same version as repo-main.
just errors from your checkout (./scrpits/cairo_test.sh
) would be much more beneficial.
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 3 files reviewed, 2 unresolved discussions (waiting on @orizi)
corelib/src/iter/traits/iterator.cairo
line 102 at r1 (raw file):
Previously, orizi wrote…
yes - it seems that finding
Self
as an impl in trait context is yet to be supported.
working on it.note:
please don't mention errors you got from the LSP - as this may not be the same version as repo-main.
just errors from your checkout (./scrpits/cairo_test.sh
) would be much more beneficial.
I see, I'll keep this PR opened for now then.
Running tests failed without any diagnostics, so I thought that the lsp errors could help pinpoint the potential underlying issues, but I'll keep this in mind. Thank you!
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 r1, 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @julio4)
corelib/src/iter/traits/iterator.cairo
line 102 at r1 (raw file):
Previously, julio4 (Julio) wrote…
I see, I'll keep this PR opened for now then.
Running tests failed without any diagnostics, so I thought that the lsp errors could help pinpoint the potential underlying issues, but I'll keep this in mind. Thank you!
Now it works - feel free return.
you do still need to have Self
used explicitly.
corelib/src/iter/traits/collect.cairo
line 68 at r2 (raw file):
/// assert_eq!(c.arr, array![0, 1, 2, 3, 4]); /// ``` pub trait FromIterator<T, A> {
why the changes here?
599a4c0
to
a0a82a8
Compare
Previously, orizi wrote…
I reverted to +Destruct |
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 3 files reviewed, 3 unresolved discussions (waiting on @orizi)
corelib/src/iter/traits/iterator.cairo
line 99 at r1 (raw file):
Previously, orizi wrote…
doc
Done.
corelib/src/iter/traits/iterator.cairo
line 102 at r1 (raw file):
Previously, orizi wrote…
Now it works - feel free return.
you do still need to haveSelf
used explicitly.
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 3 of 3 files at r3, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @julio4)
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.
Reviewed 3 of 3 files at r3, 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)
Implementing
collect
onIterator
.Examples
Using the 'turbofish' instead of annotating
doubled
:Using artial type hint
_
with the turbofish: