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

Basic iterator support #156

Merged
merged 1 commit into from
Oct 13, 2020
Merged

Basic iterator support #156

merged 1 commit into from
Oct 13, 2020

Conversation

udoprog
Copy link
Collaborator

@udoprog udoprog commented Oct 13, 2020

This is just a POC for adding iterator support to Rune.

The Iterator type is a type-erased implementation of all various forms of iterators that are supported.

This allows for the following:

let values = [1, 2, 3];
values.iter().map(|n| n + 1).filter(|n| n > 2).collect_vec()

This adds support for:

  • size_hint - To return the expected size of the iterator.
  • map - To map an iterator.
  • filter - To filter an iterator.
  • rev - To reverse an iterator, which is only supported for double-ended iterators. Else it will panic.
  • chain - To chain two iterators.
  • enumerate - To create an enumerating iterator, which is only supported by exact-size iterators. This is detected if the lower and upper bound of size_hint agrees. Object iterators specifically doesn't have a known size (Same as the Rust impl, but dynamically).
  • Coercion into an iterator for Vec, Object, and Option.

@udoprog udoprog added the enhancement New feature or request label Oct 13, 2020
@udoprog udoprog force-pushed the iterator branch 7 times, most recently from 1974be7 to 323e477 Compare October 13, 2020 19:01
@udoprog udoprog changed the title POC Iterator Basic iterator support Oct 13, 2020
@udoprog udoprog merged commit 5f90697 into master Oct 13, 2020
@udoprog udoprog deleted the iterator branch October 13, 2020 20:59
@udoprog udoprog added the changelog Issue has been added to the changelog label Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Issue has been added to the changelog enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant