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

Add Repeat and RepeatN #397

Merged
merged 8 commits into from Oct 7, 2017

Conversation

Projects
None yet
3 participants
@cuviper
Copy link
Member

cuviper commented Jul 11, 2017

This adds:

  • unindexed, infinite iter::repeat(elt) -> Repeat
  • indexed, finite iter::repeatn(elt, n) -> RepeatN
  • Repeat methods take(n) and zip(iter) convert to RepeatN

This extends #337, opened separately for review since it's a fairly major change.

@cuviper

This comment has been minimized.

Copy link
Member Author

cuviper commented Jul 11, 2017

I wanted to add some symmetry such that IndexedParallelIterator::zip could also accept iterators that might be truncatable, but I couldn't work out the coherence. I wrote a new trait for this, with a blanket implementation to cover the existing I: IntoParallelIterator, I::Iter: IndexedParallelIterator, but rustc couldn't be convinced that Repeat<T> doesn't overlap that. I suppose in theory a downstream crate could implement IndexedParallelIterator for their own Repeat<Foo>?

@cuviper cuviper changed the title Repeat repeatn Add Repeat and RepeatN Jul 11, 2017

@cuviper cuviper force-pushed the cuviper:repeat-repeatn branch from 366f6b7 to 74d8aa9 Sep 17, 2017

@cuviper

This comment has been minimized.

Copy link
Member Author

cuviper commented Sep 17, 2017

Rebased.

@cuviper cuviper requested a review from nikomatsakis Sep 17, 2017

@nikomatsakis
Copy link
Member

nikomatsakis left a comment

One minor nit to the documentation

/// means to shorten it, or consider using
/// [the `repeatn()` function](fn.repeatn.html) instead.
///
/// Example:

This comment has been minimized.

@nikomatsakis

nikomatsakis Sep 22, 2017

Member

I think that people write # Examples or something conventionally?

/// Creates a parallel iterator that produces `n` repeats of `elt`
/// (by cloning it).
///
/// Example:

This comment has been minimized.

@nikomatsakis

nikomatsakis Sep 22, 2017

Member

Same here.

@nikomatsakis nikomatsakis referenced this pull request Sep 22, 2017

Closed

Add Repeat #337

@cuviper cuviper force-pushed the cuviper:repeat-repeatn branch from 74d8aa9 to 8a92d6d Sep 23, 2017

@cuviper

This comment has been minimized.

Copy link
Member Author

cuviper commented Sep 23, 2017

Updated.

@nikomatsakis

This comment has been minimized.

Copy link
Member

nikomatsakis commented Oct 6, 2017

Needs rebase. =)

@cuviper cuviper force-pushed the cuviper:repeat-repeatn branch 2 times, most recently from 914088b to dc9197f Oct 6, 2017

ChristopherDavenport and others added some commits May 13, 2017

@cuviper cuviper force-pushed the cuviper:repeat-repeatn branch from dc9197f to 1773693 Oct 7, 2017

@cuviper

This comment has been minimized.

Copy link
Member Author

cuviper commented Oct 7, 2017

bors r=nikomatsakis

bors bot added a commit that referenced this pull request Oct 7, 2017

Merge #397
397: Add Repeat and RepeatN r=nikomatsakis a=cuviper

This adds:
- unindexed, infinite `iter::repeat(elt) -> Repeat`
- indexed, finite `iter::repeatn(elt, n) -> RepeatN`
- `Repeat` methods `take(n)` and `zip(iter)` convert to `RepeatN`

This extends #337, opened separately for review since it's a fairly major change.
@bors

This comment has been minimized.

Copy link
Contributor

bors bot commented Oct 7, 2017

@bors bors bot merged commit 1773693 into rayon-rs:master Oct 7, 2017

2 checks passed

bors Build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@cuviper cuviper deleted the cuviper:repeat-repeatn branch Oct 12, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.