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(corelib): FromIterator takes IntoIterator instead of Iterator #7226

Merged
merged 2 commits into from
Feb 16, 2025

Conversation

julio4
Copy link
Contributor

@julio4 julio4 commented Feb 5, 2025

Currently, FromIteratorTrait takes an Iterator.
This PR modify this to +IntoIterator (which is implemented by all Iterators).

This need some update on Iterator::collect (#7086) as well.
And updated implementations for:

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

Reviewed 8 of 8 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @julio4)


corelib/src/test/array_test.cairo line 242 at r1 (raw file):

    let arr = FromIterator::from_iter((0..5_u32));
    assert_eq!(arr, array![0, 1, 2, 3, 4]);
}

Suggestion:

fn test_array_from_iterator() {
    assert_eq!(FromIterator::from_iter(0..5_u32), array![0, 1, 2, 3, 4]);
}

corelib/src/test/array_test.cairo line 247 at r1 (raw file):

fn test_array_from_collect() {
    let arr: Array<u32> = (0..5_u32).into_iter().collect();
    assert_eq!(arr, array![0, 1, 2, 3, 4]);

Suggestion:

    assert_eq!((0..5_u32).into_iter().collect(), array![0, 1, 2, 3, 4]);

corelib/src/iter/traits/collect.cairo line 22 at r1 (raw file):

///
/// ```
/// let v = FromIterator::from_iter((0..5_u32));

Suggestion:

/// let v = FromIterator::from_iter(0..5_u32);

corelib/src/test/byte_array_test.cairo line 499 at r1 (raw file):

    let arr: Array<u8> = array!['h', 'e', 'l', 'l', 'o'];
    let ba: ByteArray = FromIterator::from_iter(arr);
    assert_eq!(ba, "hello");

Suggestion:

    let ba: ByteArray = FromIterator::from_iter(array!['h'_u8, 'e', 'l', 'l', 'o']);
    assert_eq!(ba, "hello");

Copy link
Contributor Author

@julio4 julio4 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, 4 unresolved discussions (waiting on @orizi)


corelib/src/iter/traits/collect.cairo line 22 at r1 (raw file):

///
/// ```
/// let v = FromIterator::from_iter((0..5_u32));

Done.


corelib/src/test/array_test.cairo line 242 at r1 (raw file):

    let arr = FromIterator::from_iter((0..5_u32));
    assert_eq!(arr, array![0, 1, 2, 3, 4]);
}

Done.


corelib/src/test/array_test.cairo line 247 at r1 (raw file):

fn test_array_from_collect() {
    let arr: Array<u32> = (0..5_u32).into_iter().collect();
    assert_eq!(arr, array![0, 1, 2, 3, 4]);

Done.
There's still the need for the <ByteArray> type information.


corelib/src/test/byte_array_test.cairo line 499 at r1 (raw file):

    let arr: Array<u8> = array!['h', 'e', 'l', 'l', 'o'];
    let ba: ByteArray = FromIterator::from_iter(arr);
    assert_eq!(ba, "hello");

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.

:lgtm:

Reviewed 3 of 3 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @julio4)


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

@julio4 julio4 force-pushed the feat/from_iterator_takes_into_iter branch from fe25d41 to aac6cb8 Compare February 14, 2025 16:52
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 3 of 3 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @julio4)


a discussion (no related file):

Previously, orizi wrote…

@gilbens-starkware for 2nd eye.

ping

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:

Reviewed 4 of 8 files at r1, 1 of 3 files at r2, 3 of 3 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @julio4)

@orizi orizi added this pull request to the merge queue Feb 16, 2025
Merged via the queue into starkware-libs:main with commit 0e3a395 Feb 16, 2025
46 checks passed
@julio4 julio4 deleted the feat/from_iterator_takes_into_iter branch February 27, 2025 01:02
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.

4 participants